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

Re^5: Common Perl Pitfalls

by JavaFan (Canon)
on Apr 11, 2012 at 15:29 UTC ( #964565=note: print w/ replies, xml ) Need Help??

in reply to Re^4: Common Perl Pitfalls
in thread Common Perl Pitfalls

Yeah, that's a whole day's work.
Maybe not for you or me. But for someone who needs half a day to type
my $test = do {local $/; <HANDLE>};
it could easily be.

Comment on Re^5: Common Perl Pitfalls
Download Code
Replies are listed 'Best First'.
Re^6: Common Perl Pitfalls
by jdporter (Canon) on Apr 11, 2012 at 16:14 UTC
    half a day to type

    You keep dwelling on that, but I think you're misdirecting. He wrote, "spend half a day writing and debugging code", not "half a day to type in one line".

    If someone has a bug they need to track down, they're far more likely to waste cycles on a line like $_=do{local$/;<>}; than one like $_=read_file($file);

    Now let's compare apples to apples:

    use File::Slurp; my $text = read_file( 'filename' );
    my $text = do { local $/; open my $fh, '<', 'filename' or die "Error opening filename for read - $!"; <$fh> };

    For most programmers, the former looks sane.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2015-11-29 15:32 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (751 votes), past polls