Inspired by a recent Slashdot post (oh, the irony :-) ), I see that we're coming up to a major rollover for the UNIX 32-bit clock on Sept 9, 2001, in which we go from 999999999 to 1000000000. While this shouldn't be serious problem as much as the Y2K bug, there is potental for problems if you have used the string comparision functions for comparing dates:
use strict; my $b1 = 900000000; my $b2 = 999999999; my $a = 1000000001; print (( $b1 < $b2 ) ? "True\n" : "False\n"); print (( $b1 < $a ) ? "True\n" : "False\n"); print (( $b1 lt $b2 ) ? "True\n" : "False\n"); print (( $b1 lt $a ) ? "True\n" : "False\n");
The output of this code (on Perl 5.005, NT) is:
True True True False
Which, of course, is obvious for string comparisons. Now, while we all know as good little programmers to avoid using string comparisons when we are comparing numbers, we also know to use more than 2 digits for the year when given plenty of resources. It might be wise to take a look at any mission-critical code and verify that if you are comparing dates that you are doing it numerically. Or even better, consider switching to modules like Date::Manip or Date::Calc that will avoid this type of problem.


Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain

In reply to The Y2.001775K Bug by Masem

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.