in reply to Re: The Y2.001775K Bug
in thread The Y2.001775K Bug

masem didn't actually mean a rollover - I think he was just using it as an analogy He meant "we're coming up to a point where all the nines go to zeros and we put a one in front".

I'm not quite sure what he means by check your string comparisons, because I can't see a way that it could change the outcome of a string comparison unless you were doing something terribly foolish like

if (substr($this_dat,0,4) eq substr($that_date,0,4) {

In which case it would come up false when you clearly would have wanted it to be true.

It was an interesting snippet anyway, just like yakko's below.

____________________
Jeremy
I didn't believe in evil until I ate it.

Replies are listed 'Best First'.
Re: Re: Re: The Y2.001775K Bug
by Masem (Monsignor) on Apr 19, 2001 at 07:04 UTC
    Here's a possible way that you can run into this blunder, a good possible 'newbish' problem.
    # Generate files... my $time = time(); open FILE ">$time.txt" or die $!; print FILE $stuff; close FILE; # this is repeated often, as from CGI... # # Retrieval now... my @files = get_list_of_files(); @files = sort { $a cmb $b } @files; foreach my $file ( @files ) { do_something_with_file ( $file ); }
    If the files are created across the 9/9/01 boundary, you are going to missort these later.

    Oddly enough, I use this exact technique in my recent code snippet, notepad.pl; however, I do protect from this by sprintf'ing the time into a much much longer string that should be ok until 64-bit systems...without that sprintf, that code suffers from the same problem.

    }


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