in reply to The Marcel Perl Questionnaire
Yesterday I realized that it is Perlish to assign variables to $_ explicitly. For instance, I can say:
$_ = "LamourEstBleu"; if (/Bleu/){ print; }
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!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(ichimunki) re: assigning to $_
by ichimunki (Priest) on Feb 24, 2001 at 19:46 UTC | |
|
Re (tilly) 2: The Marcel Perl Questionnaire
by tilly (Archbishop) on Feb 24, 2001 at 22:43 UTC | |
by premchai21 (Curate) on Feb 26, 2001 at 00:26 UTC | |
by tilly (Archbishop) on Feb 26, 2001 at 02:12 UTC | |
by premchai21 (Curate) on Feb 27, 2001 at 07:04 UTC |