Chas. Owens wrote:
That date format is directly sortable, so unless you have another reason to convert to epoch time just use a string comparison in the sort. I would probably write the code like this:
Unfortunately, the data is not directly sortable since the date is in American format, not Système International (SI). SI dates are directly sortable and are the preferred format for storing dates.
I would use a heap to sort: #!/usr/bin/perl use strict; use warnings; my %data = (); while( <DATA> ){ my ( $path, $am_date ) = split m{ \@ }msx, $_, 2; my ( $mo, $day, $yr, $time ) = split m{ \- }msx, $am_date; $data{$yr}{$mo}{$day}{$time} = $_; } print Dumper \%data; for my $yr ( sort { $a <=> $b } keys %data ){ for my $mo ( sort { $a <=> $b } keys %{ $data{$yr} } ){ for my $day ( sort { $a <=> $b } keys %{ $data{$yr}{$mo} } ){ for my $time ( sort { $a cmp $b } keys %{ $data{$yr}{$mo}{$day} } ){ print $data{$yr}{$mo}{$day}{$time}; } } } } __DATA__ foo/bar/b...@07-23-2009-11.42.02 foo/bar/b...@07-22-2009-10.00.00 q...@07-24-2009-23.59.00 /some/p...@06-10-2009-12.30.13 -- Just my 0.00000002 million dollars worth, Shawn Programming is as much about organization and communication as it is about coding. Regardless of how small the crowd is, there is always one in it who has to find out the hard way that the laws of physics apply to them too. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/