in reply to Counter that won't work with the IP Log
localtime(time) in an array context returns a list of time elements ($sec,$min ...), In your case you are using it in a scalar context in which case it returns a formatted time string ( Thu Nov 15 03:32:13 2001 ). If this is what you want your delta date calculations will probably need the assistance of a perl module like Date::Calc.
But there is an easier way that Kanji's example although not quite right, illustrates.
Your timestamps will now be in system time format but a simple three liner (hey using localtime() ) can coerce them back into human readable format.# code frag written in long hand for clarity (I hope) my $delta_day; my $now = time(); my $oldiptime = ---from your file -- (($now - $oldiptime) >= 86400) ? ($delta_day = 1) : ($delta_day = 0);
Lastly you can vastly simplify your script by going to your favorite Perl reference and first reading about hashes and then reading about many options for 'tieing' external hashes. Here's a teaser.
# code fragment there's a use strict lusting above if ( exists ($IP_LIST{$ip} ) { go check delta day and stuff } else { # sdd it $IP_List{$ip} = $now; }
good luck
mitd-Made in the Dark
'Interactive! Paper tape is interactive!
If you don't believe me I can show
you my paper cut scars!'
|
|---|