more useful options | |
PerlMonks |
Re: Passing epoch time to function to compare open session time and close session timeby perloHolic() (Beadle) |
on Feb 06, 2015 at 14:50 UTC ( [id://1115787]=note: print w/replies, xml ) | Need Help?? |
Here I have rejigged your code somewhat to compile under strict and warnings, however I have tried to leave it as original as possible so you find it familiar and easy to understand.
I used this as an example fo input: Jan 31 08:40:19 ubuntu01 sshd[32346]: pam_unix(sshd:session): session opened for user user1 by (uid=1) Jan 31 08:45:19 ubuntu01 sshd[32346]: pam_unix(sshd:session): session closed for user user1 by (uid=1) That I found in what I believe to be an alternate post of yours. As you will be able to see from a simple output debug I put in, epoch is printed on both 'opened' and 'closed' and prints the same number, hence you're '0's issue. I would suggest rethinking your method of determing 'time' and the difference between a 'connection open' time and a 'connection closed' time. By no means am I guaranteeing that this code is the best way to do it, it is simply my honest interpretation from your's to 'safe/compilable code' - My usual caveat applies - all edits and suggestions and errors found are more than welcomed as always. All the best - your ever faithfull functioning perloHolic
In Section
Seekers of Perl Wisdom
|
|