Just another Perl shrine | |
PerlMonks |
comment on |
( [id://3333]=superdoc: 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 reply to Re: The Marcel Perl Questionnaire
by sierrathedog04
|
|