Re: looking a one liner "to return the value while clearing the argument"

2004-12-11 Thread Peter Scott
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Edward WIJAYA) writes: >On Fri, 10 Dec 2004 09:48:26 -0500, Felix Li <[EMAIL PROTECTED]> >wrote: > >> Is there "a one liner" that performs the equivalent of >> sub ReturnAndClear { >>my $temp=$_[0]; >>$_[0]=undef; >>return $temp; >>

Re: Mod_Perl Pass Associative Arrays

2004-12-11 Thread James Taylor
Chris Devers wrote: On Fri, 10 Dec 2004, James Taylor wrote: Hi everyone, wondering if anyone knew how to pass an associative array via POST to mod_perl. Something like: HTML forms don't really provide for complex data structures, so any solution is going to have to be cobbled together. I thi

traversing (and accessing values in) a hash of hashes

2004-12-11 Thread James marks
Hello folks, I'm wondering if any of you could help me with a code problem? I'm relatively new to Perl, coming to it from AppleScript, and I've written a Perl script that parses my server access_log and creates a hash of hashes that looks essentially like this: 192.168.1.1 =

Re: traversing (and accessing values in) a hash of hashes

2004-12-11 Thread Oliver Schnarchendorf
On Sat, 11 Dec 2004 15:58:48 -0800, James marks wrote: > I want to traverse that hash of hashes to extract the user agent of > each IP whose user type is "robot" like this: > > LIST OF ROBOTS VISITING SITE: > 192.168.1.1 "...GoogleBot..." > 192.168.1.4 "...Yahoo! Slurp..." > etc... #!/usr/local/b

Re: traversing (and accessing values in) a hash of hashes

2004-12-11 Thread Lawrence Statton
> > I want to traverse that hash of hashes to extract the user agent of > > each IP whose user type is "robot" like this: > D'OH! I just re-read the problem ... amend to read print "$key \"$log{$key}{user_agent}\"\n" if $log{$key}{user_type} eq 'robot'; -- -- -- -- -- -- -- --

Re: traversing (and accessing values in) a hash of hashes

2004-12-11 Thread Lawrence Statton
> Hello folks, > > I'm wondering if any of you could help me with a code problem? I'm > relatively new to Perl, coming to it from AppleScript, and I've written > a Perl script that parses my server access_log and creates a hash of > hashes that looks essentially like this: > > 192.168.1.1 = >

Re: traversing (and accessing values in) a hash of hashes

2004-12-11 Thread James marks
In the script, there are two variables produced from a regexp match against the current line in the access_log: $new_ip $user_agent and one that is determined by a subroutine that looks for clues that the user_agent is a robot: $user_type This is the subroutine that builds the hash of hashes. I

Re: traversing (and accessing values in) a hash of hashes

2004-12-11 Thread Jonathan Paton
Dear James, A way to work with that datastructure would be: my %hash = ...; my @robots; for my $ip (keys %hash) { my $type = $hash{$ip}{type}; push @robots, [ $ip, $hash{$ip}{agent} ] if $type eq "robot"; } I suggest you use an array of hashes, in the form: my @array = ( { ip => .

Re: traversing (and accessing values in) a hash of hashes

2004-12-11 Thread Lawrence Statton
> In the script, there are two variables produced from a regexp match > against the current line in the access_log: > > $new_ip > $user_agent > > and one that is determined by a subroutine that looks for clues that > the user_agent is a robot: > > $user_type > > This is the subroutine that bu

Re: traversing (and accessing values in) a hash of hashes

2004-12-11 Thread John W. Krahn
James marks wrote: Hello folks, Hello, I'm wondering if any of you could help me with a code problem? I'm relatively new to Perl, coming to it from AppleScript, and I've written a Perl script that parses my server access_log and creates a hash of hashes that looks essentially like this: 192.168

RE: Perl on Cygwin

2004-12-11 Thread Tom Proctor
I've been using Cygwin through Perl on my machine for a few months now. So far all of my scripts run identically on Cygwin and Linux. -Original Message- From: Mandar Rahurkar [mailto:[EMAIL PROTECTED] Sent: Friday, December 10, 2004 2:23 PM Cc: [EMAIL PROTECTED] Subject: Perl on Cygwin H

Re: traversing (and accessing values in) a hash of hashes

2004-12-11 Thread James marks
Jonathan, That had occurred to me part way through writing the script. I'm learning Linux, Apache, MySQL and Perl/PHP all at the same time so sometimes I get halfway through a project in one area then learn something new in another area that causes me to have to back the first project and do a