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

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

by ColonelPanic (Friar)
on Nov 13, 2012 at 15:36 UTC ( #1003641=note: print w/replies, xml ) Need Help??


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

The single-letter variable was for the purposes of the example. The example still holds with a more descriptive name--is $results_file a filehandle or a string containing the name of a file?

More knowledge about the ambiguities of Perl is always a good thing. I don't see this practice as a replacement for knowing how things work. It just adds clarity. Braces are a nice visual cue that make a filehandle variable instantly recognizable as a filehandle.



When's the last time you used duct tape on a duct? --Larry Wall
  • Comment on Re^8: Split output by tabs (bogus best practice)

Replies are listed 'Best First'.
Re^9: Split output by tabs (bogus best practice)
by shmem (Canon) on Nov 13, 2012 at 16:03 UTC
    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.

      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://1003641]
help
Chatterbox?
[Corion]: Two-way data binding means that if you change something in a text box, the corresponding variable in your Javascript gets updated immediately as well, and if you then change the variable, the corresponding text box also gets updated
[Corion]: That is a horrible approach that was also taken by Access, but if you have hooks that prevent automatic saving to the database, it is incredibly handy

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2017-03-30 07:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (355 votes). Check out past polls.