Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Using $_ as a temp var, especially in functions

by erikharrison (Deacon)
on Oct 23, 2002 at 04:26 UTC ( #207294=note: print w/ replies, xml ) Need Help??


in reply to Using $_ as a temp var, especially in functions

$_ is really not what you want. Whenever you'd say "it" in English then use $_, because that's what it is there for. Makes things clean, and it's what I, as the maintainer and reader of your code, expect.

A variable which keeps track of the last variable used has also been mused about in the past. I think it was even implemented in an experiment(this from when I was a member of p5p). The symantics are hard to tie down, and it only leads to obfuscation - it doesn't make one liners clearer, and makes larger programs into a twist of backreferences, all alike.

Cheers,
Erik

Light a man a fire, he's warm for a day. Catch a man on fire, and he's warm for the rest of his life. - Terry Pratchet


Comment on Re: Using $_ as a temp var, especially in functions

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2014-09-03 03:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (35 votes), past polls