in reply to Formatting dates
I couldn't get that mess out of my mind. So I went back and wrote the whole thing as I might do it. It really is a simple task and probably doesn't require all of the mucking around with Time::Local and such.
#!/usr/bin/perl -w use strict; my $in_file="default.db"; my $out_file="myproperdates.db"; open (IN,"$in_file") or die "Couldn't open $in_file: $!\n"; open (OUT,">$out_file") or die "Couldn't open $out_file: $!\n"; my $year = substr((localtime)[5], -2); # Purposeful. No y2k issue. See + below. my @month = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ); while(<IN>){ # This is meant to deal with 2 digit dates. Its y2k issues aren't it +s own. s!(\d\d?)/(\d\d?)/(\d\d)!"$2-$month[$1-1]-".($3 > $year ? 19 : 20).$ +3!ge; print OUT; } close IN; close OUT;
-sauoq "My two cents aren't worth a dime.";
|
|---|