in reply to file sorting question

The only really complicated part here is how to efficiently sort the file names by their numerical component. The following shows how this can be done:
use strict; use warnings; my %names; # Extract numerical component of each file name and create # key (name) / value (number) pair while (<DATA>) { chomp; ($names{$_}) = m/(\d+)/; } # Sort the keys by their values (numerically) and print print "$_\n" for sort {$names{$a} <=> $names{$b}} keys %names; __DATA__ DSCN-1.JPG DSCN-10.JPG DSCN-12.JPG DSCN-3.JPG DSCN-7.JPG