in reply to Local(*FILE);

I want to add to all replies above that in new perls (5.6.0 and later) you can use my instead of local with filehandles in open.

That is code like

local *FILE; open FILE, $filename or die "Can't open file: $!"; my $data = <FILE>; close FILE;
can be replaced with
open my $file, $filename or die "Can't open file: $!"; my $data = <$file>; close $file;

--
Ilya Martynov (http://martynov.org/)

Replies are listed 'Best First'.
Re (tilly) 2: Local(*FILE);
by tilly (Archbishop) on Jan 13, 2002 at 08:17 UTC
    As stated in perlstyle, it is very important that the debugging message includes all of the important information, including the filename. (And for those who think I sound like a broken record on this, spend a couple of hours late at night trying to figure out which file out of several thousand accessed by a script you have never seen broke the production run, and then tell me that insisting on having the filename is unreasonable...)

    A few incidental points. The first is that people seeking to slurp a file usually don't want just the first line. And secondly if you make a habit of scoping file handles tightly, there is no need to close them. Your preferences may vary, but I usually don't bother. And finally, as chip says, if you have the choice in 5.6.0+, it is better to use the 3-arg open. See Two-arg open() considered dangerous for details and discussion.

    sub slurp_file { my $file_name = shift; open(my $fh, "<", $file_name) or confess("Cannot read '$file_name': +$!"); wantarray ? <$fh> : join '', <$fh>; }

      A very hearty thanks to everyone who posted a response to my query. All were very informative!