josephjohn has asked for the wisdom of the Perl Monks concerning the following question:
foreach my $line (@file) { my @fields = split(/,/, $line); if ($fields[6] !~ /\d{2}\/\d{2}\/\d{4}/) { @tempdate = split(/\//, $fields[6]); if ($tempdate[0] < 10) { $newdate = "0" . $tempdate[0] . "/"; } else { $newdate = $tempdate[0] . "/"; } if ($tempdate[1] < 10) { $newdate = $newdate . "0" . $tempdate[1] . "/"; } else { $newdate = $newdate . $tempdate[1] . "/"; } $fields[6] = $newdate . $tempdate[2]; } $datecount{$fields[6]}++; } foreach my $date (sort(keys(%datecount))) { print "\n", $date, ": ", $datecount{$date}; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Sorting Dates
by demerphq (Chancellor) on Nov 24, 2005 at 12:20 UTC | |
Re: Sorting Dates
by Moron (Curate) on Nov 24, 2005 at 11:14 UTC | |
Re: Sorting Dates
by gjb (Vicar) on Nov 24, 2005 at 10:40 UTC | |
by josephjohn (Acolyte) on Nov 24, 2005 at 10:51 UTC | |
by gjb (Vicar) on Nov 24, 2005 at 11:11 UTC | |
by secret (Beadle) on Nov 24, 2005 at 11:17 UTC | |
Re: Sorting Dates
by josephjohn (Acolyte) on Nov 24, 2005 at 14:47 UTC |