#!/usr/bin/perl -w =head1 CONFUSION, SELF-DOUBT, AND BEER =begin text ## Well this test script was propted by a query on File::Slurp and later file slurp which led me to 'Slurp a file' (http://perlmonks.com/index.pl?node_id=50525) by AnonymousMonk: Description: Slurp a file into a scalar. Jean-Daniel Gamache webmaster@perls.org open (IN, ";} print $file_content; ## Then davorg (man with the munchies) replies with: Oops. You've just left $/ set to undef for the rest of the program. This can lead to all sorts of nastiness. Better to do something like this: my $file_text; { local $/; $file_text = ; } print $file_text; Which returns $/ to its original value once you leave the bare block. -- "Perl makes the fun jobs fun and the boring jobs bearable" - me ## This really had me confused. The original post had a block, it doesn't matter (and 'the Rock' chimes in 'It doesn't matter!') where you declare $file_content, as it has no bearing on local or $/ since {;;;;;} is a valid block!.... I was kind of in doubt of my faculties for a split second, and then I scrolled down the page, and found an AnonymousMonk node saying "Sorry, you were right!" Then it came to me (in a vision =;:): davorg had been coding drunk again. ... there's always a valuable lesson to be learned ... keep (c|n)ode-ing =end =cut # some quick test code print '$/',"is = '$/';\n"; { local $/; # in effect, makes $/ uninitialized print '$/',"is = '$/';\n"; print ; } print '$/',"is = '$/';\n"; __DATA__ I AM DATA