[26203] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 8390 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 5 14:05:20 2005

Date: Mon, 5 Sep 2005 11:05:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 5 Sep 2005     Volume: 10 Number: 8390

Today's topics:
        Analysing apache logs <sebastien.vinot@capgemini.fr>
    Re: Analysing apache logs <pseudo@codernet.net>
    Re: Analysing apache logs <sebastien.vinot@capgemini.fr>
    Re: Analysing apache logs <pseudo@codernet.net>
    Re: Analysing apache logs <sebastien.vinot@capgemini.fr>
    Re: Analysing apache logs <sebastien.vinot@capgemini.fr>
    Re: Hacking a script (makemenu.pl) <Raffles01@kconline.com>
    Re: Hacking a script (makemenu.pl) <Raffles01@kconline.com>
    Re: How to identify which interface a broadcast packet  <ThomasKratz@REMOVEwebCAPS.de>
    Re: maintainable code? <flavell@ph.gla.ac.uk>
    Re: maintainable code? <tadmc@augustmail.com>
    Re: maintainable code? <matthew.garrish@sympatico.ca>
    Re: maintainable code? <ngoc@yahoo.com>
    Re: maintainable code? xhoster@gmail.com
    Re: Padding Problem UPDATE (Still broken) <hal@thresholddigital.com>
    Re: Tracking Dependencies <hal@thresholddigital.com>
        Where to begin with Perl 6 <john@castleamber.com>
    Re: Where to begin with Perl 6 <mark.clementsREMOVETHIS@wanadoo.fr>
    Re: Where to begin with Perl 6 <sisyphus1@nomail.afraid.org>
    Re: Where to begin with Perl 6 <john@castleamber.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 5 Sep 2005 16:13:31 +0200
From: "Sébastien V" <sebastien.vinot@capgemini.fr>
Subject: Analysing apache logs
Message-Id: <dfhjqb$itd$1@s1.news.oleane.net>

I'd like to make a specific analysis with my apache logs of my website (I'm
Perl newbee).

This website is a B2B, then I'd like to "know" which company is behind each
IP that visits my site. I googled with no success.

Is there a Perl solution to make such links (I'm not sure).

Sebastien




------------------------------

Date: Mon, 05 Sep 2005 09:18:10 -0500
From: Willie Wilson <pseudo@codernet.net>
Subject: Re: Analysing apache logs
Message-Id: <1125930041_5311@spool6-east.superfeed.net>

Sébastien V wrote:
> I'd like to make a specific analysis with my apache logs of my website (I'm
> Perl newbee).
> 
> This website is a B2B, then I'd like to "know" which company is behind each
> IP that visits my site. I googled with no success.
> 
> Is there a Perl solution to make such links (I'm not sure).
> 
> Sebastien
> 
> 

I'm a bit confused as to what you are looking for--perhaps you could 
elaborate a bit more?

It sounds like you are wanting to know who the IP belongs to, in which 
case, you could do a WHOIS query (by using the 'whois' utility, for 
example).

Please elaborate a bit more.

-Willie

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----


------------------------------

Date: Mon, 5 Sep 2005 16:24:14 +0200
From: "Sébastien V" <sebastien.vinot@capgemini.fr>
Subject: Re: Analysing apache logs
Message-Id: <dfhkef$jb6$1@s1.news.oleane.net>

Willie Wilson wrote:
> Sébastien V wrote:
>> I'd like to make a specific analysis with my apache logs of my
>> website (I'm Perl newbee).
>>
>> This website is a B2B, then I'd like to "know" which company is
>> behind each IP that visits my site. I googled with no success.
>>
>> Is there a Perl solution to make such links (I'm not sure).
>>
>> Sebastien
>>
>>
>
> I'm a bit confused as to what you are looking for--perhaps you could
> elaborate a bit more?
>
> It sounds like you are wanting to know who the IP belongs to, in which
> case, you could do a WHOIS query (by using the 'whois' utility, for
> example).
>
> Please elaborate a bit more.
>

Okay, for example I have the IP : 0.1.2.3 and I'd like to know this is a PC
from the IBM network.

I don't know if a whois query will answer what I expect and if yes is there
a Perl module for this kind of query ?

Sebastien.




------------------------------

Date: Mon, 05 Sep 2005 09:33:35 -0500
From: Willie Wilson <pseudo@codernet.net>
Subject: Re: Analysing apache logs
Message-Id: <1125930967_5501@spool6-east.superfeed.net>

Sébastien V wrote:
> Okay, for example I have the IP : 0.1.2.3 and I'd like to know this is a PC
> from the IBM network.
> 
> I don't know if a whois query will answer what I expect and if yes is there
> a Perl module for this kind of query ?
> 
> Sebastien.
> 
> 

I don't know if a WHOIS query will answer this either, but if they have 
static IP addresses assigned, then chances are that it will show who it 
belongs to.  You can always call the external whois program, if you have it.

Searching CPAN for "WHOIS", here are the results I came up with; one of 
them is bound to have what you want.
http://search.cpan.org/search?query=WHOIS&mode=all

-Willie

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----


------------------------------

Date: Mon, 5 Sep 2005 16:36:30 +0200
From: "Sébastien V" <sebastien.vinot@capgemini.fr>
Subject: Re: Analysing apache logs
Message-Id: <dfhl5e$joq$1@s1.news.oleane.net>

Willie Wilson wrote:

>
>
> Searching CPAN for "WHOIS", here are the results I came up with; one
> of
> them is bound to have what you want.
> http://search.cpan.org/search?query=WHOIS&mode=all
>
> -Willie

Thanks for all thes keys, I'll investigate deeper while learning more Perl
:)





------------------------------

Date: Mon, 5 Sep 2005 17:02:28 +0200
From: "Sébastien V" <sebastien.vinot@capgemini.fr>
Subject: Re: Analysing apache logs
Message-Id: <dfhmm5$kk1$1@s1.news.oleane.net>

Finally I found Net::Whois::IANA which seems to work !

Thanks Willie W.




------------------------------

Date: Mon, 5 Sep 2005 10:56:47 -0500
From: "Frank Louden" <Raffles01@kconline.com>
Subject: Re: Hacking a script (makemenu.pl)
Message-Id: <zbadnZLOSvSj9YHeRVn-iw@kconline.com>

Thank you John.

Actually I did get the program to work late last night but I have to load
@ARGV inside of the script. This is fine as my use for the script is to
build a menu of all of the HTML files inside of a directory and setting ARGV
to "*.htm*" in the script just means that I loose some of the options since
I can't get my info from the command line. That's all right for now. I am
sure you're right about this difficulty being OS related. Unfortunately, a
lot of us have to work on MS systems.

Thanks to all for your suggestions and help.

"John W. Krahn" <someone@example.com> wrote in message
news:_QPSe.216630$9A2.71758@edtnps89...
> Frank Louden wrote:
> > Hi. Infrequent hacker here.
> >
> > (Originally posted to alt.comp.lang.perl. Not much happening over
there!)
> > (OK, then to comp.lang.perl where a kind soul redirected me.)
> >
> > I've spent the last two days trying to hack H. Churchyard's makemenu.pl
so
> > it will work on my WinME PC. I've got lots of hair but I won't have for
> > long.
> >
> > If there is anyone out there that knows this script, I think I might
learn
> > quite a bit by hacking my way thru this one but I could sure use some
help.
> >
> > I'm not looking for a working script or someone to do it for me. I'd
just
> > like to understand what's going on here and why I am having such a tough
> > time getting very far with this. I'm using Activestate's perl, v5.8.6
built
> > for MSWin32-x86-multi-thread.
>
> It looks like makemenu.pl was created using the a2p program (Awk to Perl
> translator) on makemenu.awk.
>
> perldoc a2p
>
>
> If you have a more recent version of a2p it should produce a more
up-to-date
> perl program.
>
>
> > There are two "eval" lines here...
> >
> > eval "exec /usr/local/bin/perl -S $0 $*"  if $running_under_some_shell;
>
> This is superfluous in a perl program if the first line
> (#!/usr/local/bin/perl) is the correct location of perl.
>
>
> > and...
> >
> > eval '$'.$1.'$2;' while $ARGV[0] =~ /^(title=|toc=|dirprefix=)(.*)/ &&
> > shift;
>
> It appears that this is just sort-of imitating the perl '-s' command line
switch.
>
>
> > The first is unnecessary (I think) and the second is extracting info
from
> > the command line.
> >
> > I don't know how advanced this script might be but it seems to be using
> > lot's of tricks that aren't taught in "Learning Perl on Win32 Systems".
;^)
> >
> > Anyway, if there is someone that can spare the time to share some of
their
> > knowledge with me, I'd be grateful.
> >
> > I would attempt to contact the author of this script if I knew how. I've
> > used it "as is" on Linux and it works quite well for what I am wanting
to
> > do.
> >
> > Here's the error I get...
> >
> > F:\Programming\Perl\HTML Menu Project>perl -d test2.pl title="My Menu"
toc=1
> > *.htm > My_Menu.htm
> > Win32::OLE operating in debugging mode: _Unique => 1
> > Can't open *.htm: No such file or directory at test2.pl line 12.
>
> DOS/Windows command processor (command.com/cmd.exe) does not expand
wildcard
> characters (like * or ?) so your perl program is trying to process the
literal
> file name '*.htm'.
>
> perldoc -f glob
> perldoc File::Glob
>
>
>
>
> John
> -- 
> use Perl;
> program
> fulfillment




------------------------------

Date: Mon, 5 Sep 2005 11:07:51 -0500
From: "Frank Louden" <Raffles01@kconline.com>
Subject: Re: Hacking a script (makemenu.pl)
Message-Id: <r7GdnREemqhE94HeRVn-og@kconline.com>

For anyone interested, the scripts for this program are available at...

http://www.crossmyt.com/hc/htmlchek/htmlchek.html

 ...near the bottom of the page.

It's old software. But for me, I expect a good lesson in regular expressions
and some other stuff.

Thanks again y'all!



"Frank Louden" <Raffles01@kconline.com> wrote in message
news:JsednZ2dnZ2u7UbznZ2dnfAJht6dnZ2dRVn-0J2dnZ0@kconline.com...
> Hi. Infrequent hacker here.
>
> (Originally posted to alt.comp.lang.perl. Not much happening over there!)
> (OK, then to comp.lang.perl where a kind soul redirected me.)
>
> I've spent the last two days trying to hack H. Churchyard's makemenu.pl so
> it will work on my WinME PC. I've got lots of hair but I won't have for
> long.
>
> If there is anyone out there that knows this script, I think I might learn
> quite a bit by hacking my way thru this one but I could sure use some
help.
>
> I'm not looking for a working script or someone to do it for me. I'd just
> like to understand what's going on here and why I am having such a tough
> time getting very far with this. I'm using Activestate's perl, v5.8.6
built
> for MSWin32-x86-multi-thread.
>
> There are two "eval" lines here...
>
> eval "exec /usr/local/bin/perl -S $0 $*"  if $running_under_some_shell;
>
> and...
>
> eval '$'.$1.'$2;' while $ARGV[0] =~ /^(title=|toc=|dirprefix=)(.*)/ &&
> shift;
>
> The first is unnecessary (I think) and the second is extracting info from
> the command line.
>
> I don't know how advanced this script might be but it seems to be using
> lot's of tricks that aren't taught in "Learning Perl on Win32 Systems".
;^)
>
> Anyway, if there is someone that can spare the time to share some of their
> knowledge with me, I'd be grateful.
>
> I would attempt to contact the author of this script if I knew how. I've
> used it "as is" on Linux and it works quite well for what I am wanting to
> do.
>
> Here's the error I get...
>
> F:\Programming\Perl\HTML Menu Project>perl -d test2.pl title="My Menu"
toc=1
> *.htm > My_Menu.htm
> Win32::OLE operating in debugging mode: _Unique => 1
> Can't open *.htm: No such file or directory at test2.pl line 12.
>
> And I have several small HTML files with the ".htm" extension in this
> directory.
>
> I've stripped this script down to what I think is the barest essentials
for
> testing. I don't expect this fragment to do anything I'm just trying to
get
> over a hump. I hit the "while (<>)" line and I get nothing. Here's what I
> have at this time...
>
> $title = ''; $toc = 0; $dirprefix = '';
> eval '$'.$1.'$2;' while $ARGV[0] =~ /^(title=|toc=|dirprefix=)(.*)/ &&
> shift;
> $[ = 1;                 # set array base to 1
> $\ = "\n";              # set output record separator
> foreach $X (@ARGV) {
>     if ($X =~ /^[^=]+=/) {
>         print STDERR "Apparent misspelled or badly-placed command-line
> option $\
> &";
>         print STDERR "Attempting to continue anyway...";}}
> $accum = ''; $haccum = '';
> $xRS = $/;
> #
> while (<>) {
>     if ($_ =~ /$xRS$/o) {chop;} # strip record separator
>     if (($.-$FNRbase) == 1) {
>         if ($. == 1) {
>             if (!$title) {
>                 $title = 'Menu for HTML files';}
>             print "<html><head><title>$title</title></head>";
>             print "<body><h1>$title</h1><hr><ul>";}
>         else {
>             if ($toc) {
>                 &liout();}}
>         $hlevel = 0;}
>
> };
>
> Thanks in advance.
>
> Raffles
>
>
>




------------------------------

Date: Mon, 05 Sep 2005 13:26:16 +0200
From: Thomas Kratz <ThomasKratz@REMOVEwebCAPS.de>
Subject: Re: How to identify which interface a broadcast packet comes in on?
Message-Id: <431c2b58$0$11219$bb690d87@news.main-rheiner.de>

Lincoln Yeoh wrote:
> Hi,
> 
> If I have a program listening on 0.0.0.0:(someport) on all interfaces,
> how do I know which network interface a broadcast packet is coming in
> on - assuming Linux and _many_ interfaces. And how do I set which
> interface a frame will leave on, assuming I'm sending a raw frame (no
> IP address, just the ethernet address).
> 
> If I use C, it seems I'm to use the IP_PKTINFO socket options,
> send/recv the ancillary messages and set/check the  ipi_ifindex value.
> 
> struct in_pktinfo {
> 	unsigned int	ipi_ifindex; 	/* Interface index */
> 	struct in_addr	ipi_spec_dst;	/* Local address */
> 	struct in_addr	ipi_addr;	/* Header Destination address
> */
> };
> 
> How would I achieve the same thing in Perl? 
> 
> This would be useful for writing something like a DHCP server - such a
> server could receive packets with source IP addresses of 0.0.0.0
> destined to 255.255.255.255, and will need to know which interface the
> packet is coming in from AND the source ethernet (or other link layer)
> address so that it can send the replies out the right interface.

Here is a way using IO::Socket::INET:

use strict;
use warnings;

use IO::Socket;

my $s = IO::Socket::INET->new(
    Listen => 5,
    LocalPort => 7777,
) or die $@;

my $c = $s->accept();
print inet_ntoa($c->sockaddr());

Thomas

-- 
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*\043),,mg,@_=map{[split'']}split;{#>J~.>_an~>>e~......>r~
$_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
'%',s,(.),\$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e.r^.>l^..>k^.-


------------------------------

Date: Mon, 5 Sep 2005 11:14:10 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: maintainable code?
Message-Id: <Pine.LNX.4.62.0509051110440.9224@ppepc56.ph.gla.ac.uk>

On Mon, 5 Sep 2005, John Bokma wrote:

> CGI.pm is 7500+ :-D. (But almost halve of it is documentation).

And a fair bit of that code is involved with its technique of 
incremental loading.  Under the covers, it's pretty modular, as far as 
I can see.

> > Or I have to change it as soon as possible if I do not want my current 
> > and future colleagues will complain me as unexperience?
> 
> I think that depends much more on your coding style.

Fair comment ;-)


------------------------------

Date: Mon, 5 Sep 2005 08:17:46 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: maintainable code?
Message-Id: <slrndhohbq.m5i.tadmc@magna.augustmail.com>

ngoc <ngoc@yahoo.com> wrote:

> I do not 
> want to use our. I remember 'NOT SURE' that two programs running with 
> two our variables with same name, it modifies each other values.


That is not true in the usual runtime environment.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Mon, 5 Sep 2005 10:29:59 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: maintainable code?
Message-Id: <EDYSe.4331$vN.151983@news20.bellglobal.com>


"John Bokma" <john@castleamber.com> wrote in message 
news:Xns96C832EF6547Ccastleamber@130.133.1.4...
> ngoc <ngoc@yahoo.com> wrote:
>
>> Hi
>> Now I have a perl program with 5000 lines of code in a file. I want to
>> divide it to many files, so that it is easy to maintain.
>
> Can you come up with a better design?
>
>> But I face a
>> lot of trouble with many subroutines using class variables.
>
> Ouch (I guess you mean global variables).
>
>> Is a 5000 lines of code in one file perl program normal in perl's world?
>
> CGI.pm is 7500+ :-D. (But almost halve of it is documentation).
>
> 5000 lines of actual code is quite a lot to have in one program, or at
> least, I can't find a script (so far) I have written that comes close to
> it.
>

It really depends on what the program is doing. I can think of one interface 
I wrote using the Tk extensions that went well beyond 5000 lines in the main 
program (plus many thousands more in custom modules that accompanied it). 
There was simply no way to reduce the main program any further, however, 
because all the code was required for manipulating the widgets.

To the OP, hastily breaking your code up into module files to give the 
appearance of good design will probably only make things worse. I can tell 
you from experience that someone who asks for help (and learns from it) will 
be better respected in the long run than someone who hacks code together and 
then refuses to acknowledge their faults. If you have a lead or manager you 
can ask advice of, take your code to them and find out what recommendations 
they have. The approach can be something as simple as "I wrote this code 
procedurally, but I was wondering if it should be modularized?" And then 
once you have the person engaged ask how they would approach the problem of 
breaking it up.

Matt 




------------------------------

Date: Mon, 05 Sep 2005 16:26:58 +0200
From: ngoc <ngoc@yahoo.com>
Subject: Re: maintainable code?
Message-Id: <431c62b0$1@news.broadpark.no>


> 
> It really depends on what the program is doing. I can think of one interface 
> I wrote using the Tk extensions that went well beyond 5000 lines in the main 
> program (plus many thousands more in custom modules that accompanied it). 
> There was simply no way to reduce the main program any further, however, 
> because all the code was required for manipulating the widgets.
> 
> To the OP, hastily breaking your code up into module files to give the 
> appearance of good design will probably only make things worse. 
Excellent advice
I can tell
> you from experience that someone who asks for help (and learns from it) will 
> be better respected in the long run than someone who hacks code together and 
> then refuses to acknowledge their faults. If you have a lead or manager you 
> can ask advice of, take your code to them and find out what recommendations 
> they have. The approach can be something as simple as "I wrote this code 
> procedurally, but I was wondering if it should be modularized?" And then 
> once you have the person engaged ask how they would approach the problem of 
> breaking it up.
>
I am the only programmer in the team. I will try to ask around in the 
company who know perl.




------------------------------

Date: 05 Sep 2005 17:38:43 GMT
From: xhoster@gmail.com
Subject: Re: maintainable code?
Message-Id: <20050905133843.984$rW@newsreader.com>

ngoc <ngoc@yahoo.com> wrote:
> Hi
> Now I have a perl program with 5000 lines of code in a file. I want to
> divide it to many files, so that it is easy to maintain.

Why does that make it easier to maintain?  I *hate* maintaining code in
which I have to keep hunting through a bunch of other files to find the
particular sub definition I need, just because someone wanted to keep their
line count under a certain number.  Unless there is (or will be) some
inherent modularity, or other programs need to use the same set of code, I
wouldn't bother dividing it into several files just to meet some arbitrary
line count.

> But I face a
> lot of trouble with many subroutines using class variables.

Do you mean file-scoped variables?  If so, then cleaning that up would
probably improve your code regardless if whether you split it up or leave
it all in one file.

> I do not
> want to use our. I remember 'NOT SURE' that two programs running with
> two our variables with same name, it modifies each other values.

Two separate programs (running in separare perl interpretors) don't
interact with each other, unless they are specifically coded to do that.
It is more a problem of reentrance or repeatability within one program.
(Are you using mod_perl?)  But you generally shouldn't use package
variables anyway.  If you were going to do that, just leave it all in file
instead.

>
> Is a 5000 lines of code in one file perl program normal in perl's world?

I can't speak for the rest of the perl world, but it is pretty unusual for
me. I don't think it has ever taken me more than 1500 lines (not counting
__DATA__ sections or the code of used of CPAN modules) to accomplish any
single task I wanted to accomplish in Perl.

> Or I have to change it as soon as possible if I do not want my current
> and future colleagues will complain me as unexperience?

If you colleagues are competent, you should be asking them.  They probably
know far more about the specific situation (the likelihood of needing some
of those routines from other code, the level of maintenance likely to be
needed, the culter of the organization, etc.) than we do.  And if they
aren't competent, then there is no telling what they will choose to
complain about.


Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: Mon, 05 Sep 2005 12:40:25 -0400
From: Hal Vaughan <hal@thresholddigital.com>
Subject: Re: Padding Problem UPDATE (Still broken)
Message-Id: <P-mdnV0TZKVk6YHeRVn-2w@comcast.com>

sgillett wrote:

> Hi Hal,
> 
> Thanks for your suggestion, I am now using
> padding => 'standard'
> but still get the following error from the java side:
> javax.crypto.BadPaddingException: Given final block not properly padded
> 
> I have taken a look back at this thread as you suggested, and noticed that
> in your earlier posts you had the same problem, and in your post on 23rd
> August you were able to get it working with several tweaks.
> 
> Can you remember what changes you needed to make?
> 
> Thanks,
> 
> Steve.

My best guess is it was a typo (I have a slight learning disability that
makes it very hard, if not almost impossible to spot some typos if
spellchecking or syntax highlighting doesn't catch them).  My reasoning for
that is that I looked up the padding info for Perl and Java, experimented
with changing them around, then ended up with putting them both back to
what I had, and after that, it worked.  Since the settings were the same as
they were originally, my guess is that I must have mistyped something I
couldn't catch.  I never had a problem with Perl decrypting the data,
always with Java decrypting.  I guess that's because Java is so picky about
everything and has to have things perfect, whereas Perl is loose enough to
make allowances for, for example, a string not being what was expected.

Below, I've included the important program lines.  That includes setting up
the encryption in Perl (the en/de-crypt call is a simple call), and setting
up and using en/de-cryption for Java.  I hope that helps!

Hal
===========================

Here's the line I'm using for setting up encryption in Perl:

$cipher = Crypt::CBC->new( { 'key' => $pw, iv => $vector, prepend_iv => 0,
        'cipher' => 'Blowfish', 'regenerate_key' => 0 , padding => 'standard'} );

And here's the one I use for setting up decryption in Perl:

$cipher = Crypt::CBC->new( { 'key' => $pw, iv => $vector, prepend_iv => 0,
        'cipher' => 'Blowfish', 'regenerate_key' => 0 } );

On the Java side, here's how I set up and call encryption:

//myKey, myVector are strings, bEncrypted is byte[]
try {
        SecretKeySpec oKey = new SecretKeySpec(myKey.getBytes(), "Blowfish");
        IvParameterSpec oIV = new IvParameterSpec(myVector.getBytes());
        Cipher oCipher = Cipher.getInstance("Blowfish/CBC/PKCS5Padding");
        oCipher.init(Cipher.ENCRYPT_MODE, oKey, oIV );
        bEncrypted = oCipher.doFinal(bData);
} catch (Exception e) {
        return "error encrypting string";
}

And here's how I setup and call decryption in Java:

//sCryptoKey, sCryptoVector are strings, bDecrypted is byte[]
try {
        SecretKeySpec oKey = new SecretKeySpec(sCryptoKey.getBytes("UTF8"),
                "Blowfish");
        IvParameterSpec oIV = new IvParameterSpec(sCryptoVector.getBytes("UTF8"));
        Cipher oCipher = Cipher.getInstance("Blowfish/CBC/PKCS5Padding");
        oCipher.init(Cipher.DECRYPT_MODE, oKey, oIV );
        bDecrypted = oCipher.doFinal(bCrypto);
} catch (Exception e) {
        return "error decrypting incoming file".getBytes();
}


------------------------------

Date: Mon, 05 Sep 2005 13:32:59 -0400
From: Hal Vaughan <hal@thresholddigital.com>
Subject: Re: Tracking Dependencies
Message-Id: <b5udnVBdAeTSHIHeRVn-1g@comcast.com>

Solved with simple script!  (See below for info and script.)

Hal Vaughan wrote:

> I have some modules that started small (don't they all??), and has my
> project has grown, have gotten large enough that I could split them in 2
> or
> more smaller logical blocks, creating 2,3 or 4 modules instead of 1. 
> While doing I've been doing this, I also have programs that have been
> revised that they may no longer need all the modules I currently have them
> using.
> 
> I know when I run a Perl script and it calls a non-existing routine, I'll
> get an error message, but it's not always possible to quickly or easily
> make sure every possible path of program flow is checked to be sure of
> this.
> 
> I was thinking of writing a script that would go through each program or
> module I have, collect the names of all routines called and compare them
> against Perl's own functions and all the functions defined in my modules,
> but I figure there's already a way to do that either built into Perl, or
> on CPAN (which seems to be down at the moment -- or at least I can't reach
> it
> from here).  The only keyword I can think of to describe what I'm trying
> to do is dependency, and I'm not finding much useful using that.
> 
> So is there a way to track the functions called in a program or module and
> get a listing of whether those functions are built-ins, defined in the
> program, or what module each function is defined in?
> 
> Thanks for any help on this!
> 
> Hal

I didn't get any info on packages or any other way to do this, and, needing
it resolved, I did a 3am hacked script, then commented it this morning.  It
has a lot of shortcomings, but it works in general -- at least for me, so I
thought I'd post it here.  (At end.)  I am not interested in turning this
into a project.  It works for me, and that's enough.  However, I'd be
interested in hearing from people who find it useful.

Hal

=================Program Listing:========================

#!/usr/bin/perl
#==============================================================================
#Function Call Scanner (callscan)
#
#By Hal Vaughan
#Contact at hal@thresholddigital.com
#Licensed under GPL
#(c) 2005 Hal Vaughan
#
#(If you try to contact me, include something like "Perl Programming" in the
#subject to make it easy to see it isn't spam.  If you don't get a reply, in
#a few days, somehow SpamAssassin classified your e-mail as spam, so try
#again.)
#
#I can't believe I'm writing this!! I would think there's been a need for a
#program like this before, so I can't see why there isn't something like
#this already out there.  This is a 3 am hack so I could go through my
#modules and programs and elminate extra dependencies that cropped up during
#late nate debugging sessions.
#
#WHAT IT DOES: Run this program with one or two arguments (described below),
#one provides a list of directories for programs, the othe describes a list
#of directories for modules.  First, we get the list of program and module
#directories from the arguments, then we scan the list of module directories
#and read in each module.  We look for @EXPORT = qw() in the modules (you
#may want to change this if you use a different format for exporting
#function names).  We pull out the list of functions and split it into an
#array.  Once that is done, we go through all the programs and look for each
#use of each function in each module and print out a report, listing the
#line where a function name is seen, including the line number.  We then do
#the same with the modules -- making sure when we're reading a module to
#skip scanning it for calls to its own functions.
#
#Arguments:
#       --programs={comma separated list of programs}
#       --modules={comma separated list of modules}
#
#NOTE: There are a number of weaknesses to this program, and I'm sure there
#is something much better on CPAN or elsewhere that I could not find and
#nobody on the newsgroups could point me to a package to do this.  So, it
#was a quick hack to help me check which programs need actually needed which
#modules.
#
#Known shortcomings:
#- It will give false hits.  For example, if you have a function named
#"scan", and a program calls "datascan", it will be reported as using the
#function "scan".  (Comment lines and empty lines aren't checked.)  This
#could be fixed by looking for "scan(", but it'll still pick up "datascan(".
#To overcome this it would be necessary to look for "scan" preceeded by
#whitespace and other characters that could preceed a function (like ( or
# { ).  I'm sure there's more characters that fit that situation, so I
#haven't gone into it.  
#- If you don't use "@EXPORT = qw();" (the list can be spread through
#different lines), it likely won't pick up the list of functions.  This
#works for me, if you need a different format, then you can change the
#regexes.
#==============================================================================

        use strict;

        our ($dir, $file, $mod, $line, $list, $x);
        our (@prog, @mod, @modfile, @moddir, @progdir, @progfile, @list, %call);

#
#Get the lists of program and module directories from the argument list
        foreach (@ARGV) {
                if ($_ =~ /-{1,2}prog/) {
                        $line = substr($_, index($_, "=") + 1);
                        @list = split(/,/, $line);
                        push(@progdir, @list);
                }
                if ($_ =~ /-{1,2}mod/) {
                        $line = substr($_, index($_, "=") + 1);
                        @list = split(/,/, $line);
                        push(@moddir, @list);
                }
        }

#
#Get all the modules in the directories, then get all the programs.
        foreach (@moddir) {
                $dir = $_."/*pm";
                @list = glob($dir);
                foreach (@list) {
                        if (-d $_) {next;}
                        push(@modfile, $_);
                }
        }
        foreach (@progdir) {
                $dir = $_."/*";
                @list = glob($dir);
                foreach (@list) {
                        if (-d $_) {next;}
                        push(@progfile, $_);
                }
        }
        undef(@list);

#
#Now go through all the modules and get a list of all the functions in each
#module.  Put it in a hash, with the module file name as the key
        for $file (@modfile) {
                $line = filetostring($file);
                ($list) = $line =~ /\@EXPORT *?= *?qw\((.*?)\)/is;
                $list =~ s/\n/ /g;
                $list =~ s/\t+/ /g;
                $list =~ s/ +/ /g;
                @list = split(/ +/, $list);
                @{$call{$file}} = @list;
        }

#
#Scan programs and modules for matches to function names
        print "Scanning programs:\n\n";
        scan(@progfile);
        print "\n\nScanning Modules:\n\n";
        scan(@modfile);

        exit;

#
#scan a list of files (either modules or programs) for matches to functions
#in the different modules.  Use 4 loops:
#       Loop through all the files given, read each file into an array
#       Loop through each target module in the module listing
#       Loop through each line of the program/module we're scanning
#       Loop through all the functions in the target module to see if they are
#               used in that line.  If they are, add the line number, the function,
#               and the line itself to the output string.
#At the end of going through all the functions in the target module, see
#if there is an output string.  If there is, print it out.  If not, don't
#print it.  Either way, go on to the next target module, then the next file.
sub scan {
        my ($name, $file, $line, $mod, $func, $out, $x, $y, @data, @file, @func);
        @file = @_;
        for $x (0..$#file) {
                $file = $file[$x];
                $name = $file;
                $name =~ s/.*?\///;
                print "File: $name\n";
                @data = filetoarray($file);
                for $mod (sort keys %call) {
                        if ($mod eq $file) {next;}
                        @func = @{$call{$mod}};
                        $out = "";
                        for $y (0..$#data) {
                                $line = $data[$y];
                                if ($line =~ /^\s*#/ || !$line) {next;}
                                for $func (@func) {
                                        if ($line =~ /$func *\(/) {
                                                $line =~ s/\t//g;
                                                $line =~ s/\s+/ /g;
                                                $out = "$out\t\t$y\t$func\t$line\n";
                                        }
                                }
                        }
                        if ($out) {
                                $line = $mod;
                                $line =~ s/\//::/g;
                                print "\tModule: $line\n$out";
                        }
                }
        }
        print "\n";
        return;
}

#
#Quick way to load a file into a string.
sub filetostring {
        my $file = shift(@_);
        my $eol = $/;
        undef($/);
        open (STREAM,"<$file");
        my $data = <STREAM>;
        close STREAM;
        $/ = $eol;
        return $data;
}

#
#Quick way to load a file into an array.
sub filetoarray {
        my $file = shift(@_);
        my $data = filetostring($file);
        my @data = split(/\n/, $data);
        return @data;
}



------------------------------

Date: 5 Sep 2005 11:03:34 GMT
From: John Bokma <john@castleamber.com>
Subject: Where to begin with Perl 6
Message-Id: <Xns96C83DA37CBC5castleamber@130.133.1.4>

I want to read up a bit on Perl 6, but have no real idea where to start.

I mean: I am interested in two things: Parrot, and Perl 6 syntax (what 
is new). So basically less in the how and why things in Perl 6 are going 
to be as they are going to be (I doubt that I can change any of those, 
if I wanted to or even could).

I understand that for Parrot there is a low level assembly language, and 
a bit higher language on top of that. Since I want a firm understanding 
of the inner parts (I might want to contribute, but probably am not able 
to) I was thinking to start with studying Parrot.

OTOH I am very curious what new things are going to be added, etc. to 
Perl 6, i.e. how Perl 6 code looks.

For experimentation I understand I can download Parrot.

Also, I understand that there is a Perl6 that runs on HUGS (IIRC)? Is 
this the most "complete" Perl6, or are there alternatives (I have some 
experience with functional programming, Miranda/Gofer, but that's over 
10 years ago). And I read that one can add some Perl6 to Perl5 using 
modules on CPAN, but that it's not a prefered way.

Thanks for the info.

( 
  Without trying to sound presumptuous [1]:

  Somehow related: are/is there a more advanced Perl forum. I do learn 
  from quite a number of people here, even though I have been using Perl 
  for quite some time, but there are quite a number of easy questions 
  that don't add much for me. The moderated group has very very little 
  traffic.

  I will continue reading/contributing to clpm, but also need more 
  brainfood :-D.
)

[1] If that's the right word.

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


------------------------------

Date: Mon, 05 Sep 2005 13:26:08 +0200
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: Where to begin with Perl 6
Message-Id: <431c2b64$0$7853$8fcfb975@news.wanadoo.fr>

John Bokma wrote:

> ( 
>   Without trying to sound presumptuous [1]:
> 
>   Somehow related: are/is there a more advanced Perl forum. I do learn 
>   from quite a number of people here, even though I have been using Perl 
>   for quite some time, but there are quite a number of easy questions 
>   that don't add much for me. The moderated group has very very little 
>   traffic.
> 
>   I will continue reading/contributing to clpm, but also need more 
>   brainfood :-D.
> )
> 
> [1] If that's the right word.
> 
you could try the groups on the newserver at nntp.perl.org .

Also

http://www.perlmonks.org

cheers,

Mark



------------------------------

Date: Mon, 5 Sep 2005 22:50:28 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Where to begin with Perl 6
Message-Id: <431c3f51$0$4749$afc38c87@news.optusnet.com.au>


"John Bokma" <john@castleamber.com> wrote in message
news:Xns96C83DA37CBC5castleamber@130.133.1.4...
> I want to read up a bit on Perl 6, but have no real idea where to start.
>
> I mean: I am interested in two things: Parrot, and Perl 6 syntax (what
> is new).

If you're interested in perl 6 syntax, there are a number of modules that
you allow you to run various perl6 features on perl 5. See:

http://search.cpan.org/search?query=perl6&mode=dist

Cheers,
Rob




------------------------------

Date: 5 Sep 2005 14:02:26 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Where to begin with Perl 6
Message-Id: <Xns96C85BF71303Dcastleamber@130.133.1.4>

"Sisyphus" <sisyphus1@nomail.afraid.org> wrote:

> 
> "John Bokma" <john@castleamber.com> wrote in message
> news:Xns96C83DA37CBC5castleamber@130.133.1.4...
>> I want to read up a bit on Perl 6, but have no real idea where to start.
>>
>> I mean: I am interested in two things: Parrot, and Perl 6 syntax (what
>> is new).
> 
> If you're interested in perl 6 syntax, there are a number of modules that
> you allow you to run various perl6 features on perl 5. See:

"And I read that one can add some Perl6 to Perl5 using 
 modules on CPAN, but that it's not a prefered way."

I recall to have read recently that this method had some disadvantages. 
Can't remember exactly what (something like mixing Perl5 and Perl6?)

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 8390
***************************************


home help back first fref pref prev next nref lref last post