in reply to Re: Local(*FILE);
in thread Local(*FILE);
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>; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re (tilly) 2: Local(*FILE);
by Anonymous Monk on Jan 13, 2002 at 22:03 UTC |