in reply to opening consecutive files

There are two steps to this. First you need to get a list of file names and sort them in the desired order. Then, open the files in a for loop over the sorted list.

my $path = '/path/to/dir'; my @names = glob $path . '/graph_set_*.out'; # @names is in alpha order, so sort numerically my @sorted_names = sort { my ($x, $y); $a =~ /graph_set_(\d+)\.out$/ and $x = $1; $b =~ /graph_set_(\d+)\.out$/ and $y = $1; $x <=> $y } @names; # That may benefit from a Schwartzian Transform # Now, do the loop for (@sorted_names) { open local(*IN), "< $_" or die $!; # ... close IN or die $!; }
If you can write for recent enough perl, three-arg open and lexical filehandles ('open my $fh, '<', $_ or die $!;') would be good. If you want all the handles open at the same time, push $fh onto an array or assign array elements to it.

After Compline,
Zaxo