@file = # getting back the filename map $_->[0] # ascending numerical sort on desired digits sort {$a->[1] <=> $b->[1]} # anonymous array 0 => filename, 1 => desired digits map {[$_, /(\d+)\.zip/]} @file;