in reply to multiple files and hashed

On a side note, you rarely really want a C-style for(;;) loop in perl.

In your case it looks as though you want to access files called file1, file2, etc in turn.

A more perlish way of doing this (and one which is perhaps more robust against changes in the future) is to work out a list of filenames and process each of them.

You can use the glob function to get a list of files matching a pattern and then process each of those filenames. The pattern format isn't a regexp, but the same sort of pattern you'd give to a shell in Unix. For example, if you wanted to process every file in the current directory beginning with foo you could do:

my @fnames = glob("foo*"); foreach my $fname (@fnames) { # Do something then $fname... }
If you want to use more complicated patterns, or prefer regexps, you can always just get all the names into a list and use grep:
my @fnames = grep { /f(oo|u|)[0-9]{2}\.txt/ } glob("*");