No, No, my friend read Kanji first line -M is a FILE Operator It works on FILES not scalars. Also Kanji is a little confused in his use of localtime(time).

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.

# 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);
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.

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!'


In reply to Re: Counter that won't work with the IP Log by mitd
in thread Counter that won't work with the IP Log by Kage

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.