in reply to How do I sort by certain parts of a filename?

Use a sort sub-routine. Don't know how you want to sort (you give no example :), but here's a start:
# sample data my @filenames = '20001212_20011212_text.asp', '20021212_20031212_text.asp', '20031212_20041212_image.asp', '20011212_20021212_image.asp'); # loop for (sort { sort_me(); } @filenames) { # whatever print "$_\n"; } sub sort_me { # grab info from special vars $a and $b my ($a_date1,$a_date2) = split '_', $a; my ($b_date1,$b_date2) = split '_', $b; # then do your sort - eg, to sort by date1 then date2 # (in the date format I have used above) ($a_date1 <=> $b_date1) || ($a_date2 <=> $b_date2); }

$a and $b are special vars used within a sort. Read this for more info.

Note, this is a rough demo - not gonna test it unless you supply actual data and comparisons... but should give you an idea where to start.

cLive ;-)

Update - just realised you don't need to know type, so have amended code accordingly. later one, removed semi-colon that didn't affect outcome, but still looked out of place...