in reply to Filehandles, scope and warnings.

The "old" way would be to localise the glob.

open (IN, "file1") or die("can't blah blah"); while (<IN>) { print; print slurp(); } sub slurp { local *IN; my $slurp = do { local $/ = undef; open IN, "file2"; <IN>}; return $slurp; }

But these days you can use lexical filehandles.

open (my $in, "file1") or die("can't blah blah"); while (<$in>) { print; print slurp(); } sub slurp { my $slurp = do { local $/ = undef; open my $in, "file2"; <$in>}; return $slurp; }

Or, as you point out, you can use FileHandle or IO::File.

--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg