Nesh has asked for the wisdom of the Perl Monks concerning the following question:
I have the code as[17/May/2005:18:15:59 -0700]sdjhsj USERID=t70xvcy; jdhdh JSESSIONID=00 +00RDnYTABcRWOx0UN2Zq--sZB:10f408hdg [17/May/2005:18:15:59 -0700]sdjhsj USERID=t70xvcy; jdhdh JSESSIONID=00 +00RDnYTABcRWOx0UN2Zq--sZB:10f408hdg [17/May/2005:18:15:59 -0700]sdjhsj USERID=t70xvcy; jdhdh JSESSIONID=00 +00RDnYTABcRWOx0UN2Zq--sZB:10f408g13
Now the problem I am facing is that how do I push session on to the hash so that I can extract it later in order to populate the result. Appreciate your help.my $FileName = "test.txt"; my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(tim +e); open ACCESS,"< $FileName" || die "Can't open the file...."; my %User_Lst; while (<ACCESS>) { if (/:(..):(..):(..).*USERID=([a-z0-9].+; ).*JSESSIONID=([a-z0-9].+)/ +){ $l_hr=$1; $l_min=$2; $l_sec=$3; $UserID=$4; $session=$5; $UserID=~s/;.*//g; $session=~s/.*://g; $User_Lst{$UserID}=join(":",$l_hr,$l_min,$l_sec); # $User_Lst{$sessionid}=$session; } } my $l_Counter=0; #while ( (($UserID,$sessionid $TStamp) = each (%User_Lst)) and (($sess +ionid) = each (%Session_Lst))) { while ( ($UserID, $TStamp) = each (%User_Lst)) { print sprintf("Server Name :%s,\t User Name: %s ,\t Time:%s \n", +$sessionid, $UserID, $TStamp); $l_Counter++; } close ACCESS;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash problem
by rupesh (Hermit) on May 19, 2005 at 04:29 UTC | |
by bart (Canon) on May 19, 2005 at 09:24 UTC | |
by jasonk (Parson) on May 19, 2005 at 13:33 UTC | |
|
Re: Hash problem
by jdporter (Paladin) on May 19, 2005 at 04:37 UTC |