in reply to Re^4: the variable is lost
in thread the variable is lost

See my update above, and implement the advice by applying the following change:

foreach my $filename ( $a, $b ) { open my $fh, '<', $filename or die $!;

Dave