Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^9: Split output by tabs (bogus best practice)

by shmem (Canon)
on Nov 13, 2012 at 16:03 UTC ( #1003646=note: print w/ replies, xml ) Need Help??


in reply to Re^8: Split output by tabs (bogus best practice)
in thread Split output by tabs

Braces are a nice visual cue that make a filehandle variable instantly recognizable as a filehandle.

Guessed that I could whip up an example where it isn't?

qwurx [shmem] ~ > perl -le '$h = {foo => "42"}; print {$h} "foo"' Not a GLOB reference at -e line 1. qwurx [shmem] ~ >

Aha.

sort {byid} @list; map {$_->()} @stuff; print {$fh||$ofh} @vars;

Braces are no nice visual cue! They mean and do something. Using them uncalled for is either decorative or cargo cult programming.

Note that I'm not averse to the odd drink which is style, I just don't call "best practice" any blurf which doesn't hold water.


Comment on Re^9: Split output by tabs (bogus best practice)
Select or Download Code
Re^10: Split output by tabs (best practice?)
by tye (Cardinal) on Nov 13, 2012 at 17:04 UTC

    You showed an example of how the use of braces forces Perl to try to interpret something as a file handle and to complain that $h is not a file handle (just not as clearly as it might).

    That looks like evidence in support of the claimed "best practice".

    - tye        

      That looks like evidence in support of the claimed "best practice".

      Well, er... sh*t. I blew that one, it seems. Sigh..:)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2014-09-20 17:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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











    Results (160 votes), past polls