Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Perl Idioms Explained - my $string = do { local $/; <FILEHANDLE> };

by liz (Monsignor)
on Aug 29, 2003 at 14:51 UTC ( #287685=note: print w/ replies, xml ) Need Help??


in reply to Perl Idioms Explained - my $string = do { local $/; <FILEHANDLE> };

I've ++ed this, but I wonder whether it isn't time to remove glob file handles from documentation and replace them with lexically bound file handles? Instead of:

open FILEHANDLE,'filename' or die "open of 'filename' failed: $!\n";
at least show the more modern idiom:
open my $handle,'<','filename' or die "open of 'filename' failed: $!\n +";
I realize the title is "Idioms explained", but you're also teaching people new idioms this way. So from a teaching point of view, I should at least mention that there is a new and better way of opening files since Perl 5.6.0 (if I'm not mistaken).

Liz


Comment on Re: Perl Idioms Explained - my $string = do { local $/; <FILEHANDLE> };
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://287685]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2014-09-23 04:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (210 votes), past polls