in reply to Filehandles, scope and warnings.

Can I avoid ever making this mistake again?
Yes.
Should I always 'use FileHandle'?
No, all you need to do is get on with the program. Using typeglobs as filehandles is so perl4ish, it hasn't been needed since perl 5.000, although it really has been perl 5.6 that made using refs to filehandles much easier. And perl 5.6 dates from early spring 2000.
use strict; use warnings; open my $in, "file1" or die "..."; while (<$in>) { print; print slurp(); } sub slurp { my $slurp = do {local $/; open my $in, "file2" or die; <$in>} return $slurp; }
Perl --((8:>*