Hello Perl Monks
I have a text file 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
I have the code as
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;
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.