in reply to Pitfalls met while opening multiple files

Are you actually trying to (re)open stdin or stdout, or where those just the name you picked for your filehandles? From your code it looks like you are doing normal file operations. If that is the case it is not a good idea to name your handles STDIN etc. At best it creates confusing code, at worst it will cause unexpected results.

As armstd, it looks like your syntax may be confusing the compiler not to mention other programmers trying to read your code. Instead why not write:

my @open_specs = ( { 'handle' => undef, 'file' => 'input.txt', 'mode' => '<', } # Fill in more files/modes here ); foreach my $open_spec (@open_specs) { my($file, $mode) = @$open_spec{'file', 'mode'}; # hash slic +e; my $fh; open $fh, $mode, $file or die "Error opening file $file in mode $m +ode $!"; $open_spec->{'handle'} = $fh; }