Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: The Marcel Perl Questionnaireby sierrathedog04 (Hermit) |
on Feb 24, 2001 at 18:42 UTC ( [id://60653]=note: print w/replies, xml ) | Need Help?? |
My favorite special variable is good old $_.
Yesterday I realized that it is Perlish to assign variables to $_ explicitly. For instance, I can say:
At one time I would have considered the above snippet to be obfuscated, because to a novice Perl programmer it is saying "Print something, but I am not going to tell you what to print." Now I see that this Perlish way of using $_ can make code clearer, by not repeating the variable name over and over again. If a variable is a proper name, then $_ is like the word "it". Most of us when speaking French/English whatever do not refer to a subject explicitly every time, but use implicit references like "it" as well, where the meaning of "it" is apparent from the context. Similarly, the meaning of $_, which is like the word "it" in spoken language, is apparent from context. As we deepen our own Perlishness I believe that many of us will use $_ more and more often. I know I will!
In Section
Meditations
|
|