On 10/4/06, John W. Krahn <[EMAIL PROTECTED]> wrote:
Michael Alipio wrote:
> Hi,
Hello,
[ snip ]
> Now, my goal is to adapt that code, particularly
> obtaining only Start, IP, User. However, those three
> targets are not anymore located at the beginning of a
> line.
>
> "Start" is the date=.time= combination,
> "IP" is found after rem_ip=
> "User" is found after "user: "
>
> I'm not really sure how to put my regexp inside my
> hash..
>
> while ( <LOGFILE> ) {
> my %extr = (
> Start => '',
> IP => '',
> User => '',
> /what should i put here??/mg
> );
> print "Start:$extr{Start} IP:$extr{IP}
> User:$extr{User}\n\n";
> }
You don't really need a hash,
Probably not, but can someone explain what's going on here? It looks
to me like the code creates a list of k/v pairs to initialize some
hash keys with empty values, and then continues the list with a series
of k/v pairs, returned from the match captures, which immediately
overrides the vlaues for the keys that were just declared. In other
words, there are two assignments for the same keys in the same list?
Or is there some magic that happens when a hash is passed a regex in
list context so that the assignments really only happen once?
Wouldn't
my %extr = (/^(Start|IP|User|End)=(.+)/mg);
on its own achieve the same result as
my %extr = (
Start => '',
IP => '',
User => '',
End => '',
/^(Start|IP|User|End)=(.+)/mg
);
Or am I missing something?
Thanks,
-- jay
--------------------------------------------------
This email and attachment(s): [ ] blogable; [ x ] ask first; [ ]
private and confidential
daggerquill [at] gmail [dot] com
http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org
values of β will give rise to dom!