Next | Tricks of the Wizards | 147 |
We're going to detect Y2K bugs.
Perl localtime function is very badly designed.
(..., $year, ...) = localtime(...);
$q = "$mon/$day/$year"; # wrong $q = "$mon/$day/" . sprintf('%02d', $year % 100); # RIGHT
print "The year is 19$year.\n"; # wrong print "The year is 19" . $year . ".\n"; # wrong print "The year is ", 1900+$year, ".\n"; # RIGHT
Next | Copyright © 2003 M. J. Dominus |