Really good! I like your approach! And I think that robobunny got the point: if getting the right time is critical, you can't rely on yourself.

Another solution would be to synchronize your server by means of the NTP protocol, which is the best way IMHO. I studied the principles of the protocol to implement a synchronization subnet for my job, and I was greatly surprised of how much statistical studies they put in; that makes NTP a higly-reliable protocol!

Even if you don't want to invest a little to install a NTP server on your machine, you could take a look at the list of stratum 2 NTP servers and check if at least one of them offers the service by means of the daytime protocol too. To check, you can telnet to the tcp port 13 (i.e.: do a telnet host 13) and check if you get an output like:

bronto@cooper:/tmp$ telnet myTimeServer 13 Trying 192.168.1.234... Connected to myTimeServer. Escape character is '^]'. Wed Jun 26 11:01:08 2002 Connection closed by foreign host.

If so, you can get the current year using just Perl and Net::Telnet!

Ciao!
--bronto

PS: if reading a document in italian language doesn't bother you, I can send a PDF doc I wrote about NTP and our synchronization subnet to anyone interested in. Just let me know!

# Another Perl edition of a song:
# The End, by The Beatles
END {
  $you->take($love) eq $you->made($love) ;
}


In reply to Re: Re: Re: Looping by bronto
in thread Looping by Anonymous Monk

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.