Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Sort on Number Embedded in String

by TilRMan (Friar)
on Mar 23, 2005 at 05:06 UTC ( [id://441689] : note . print w/replies, xml ) Need Help??


in reply to Sort on Number Embedded in String

I want to sort on the date.

Try Date::Parse.

use Date::Parse qw( str2time ); sub date { my ($file) = @_; $file =~ /fwlog\.(.*)\.gz/ or warn "Unrecognized filename format"; return str2time($1); } my @sorted = sort { date($a) <=> date($b) } @files;