proggybilly
Programmer
Ok so I have a script that I am writing that pulls lines from a file into an array. I am then cycling through that array and looking for lines that say LOGIN. From those lines I am pulling the date (it is a log file) and the userid and placing them into variables $zdate and $zuser. What I want to do now is place those two variables into an array for sorting. Once i have them in an array, I will sort through and delete multiple instances of $zuser.. Since a user is likely to log on more than once per day, there will be several elements containing the same userid. I want my array to only show the first instance.. What I am planning on doing is taking this array, and updating an MySQL table with the last date of login for that userid.
here is what I have so far
Where I am getting hung up at is putting the array together then writing it to a file the entries in my file just say something like: Array(0x830bc68)
here is what I have so far
Code:
##
## Search mail log for expression LOGIN
##
open(MAIL_LOG, $MAIL_LOG) || die("Could not open MAIL_LOG");
@mail_line=<MAIL_LOG>;
close MAIL_LOG;
$search = " LOGIN";
foreach $mail_line(@new_mail_line){
if($mail_line=~/$search/){
$zmonth = $months{substr($mail_line,0,3)};
$zday = substr($mail_line,4,2);
$zdate = substr($mail_line,0,6);
my($zuser) = ($mail_line =~ /user=([^@]+)@/);
@zdate = $zdate;
@zuser = $zuser;
@update = (\@zdate,\@zuser);
}
}
Where I am getting hung up at is putting the array together then writing it to a file the entries in my file just say something like: Array(0x830bc68)