The stupid question is the question not asked | |
PerlMonks |
Re: my $x or my ($x)by rinceWind (Monsignor) |
on Apr 04, 2006 at 14:26 UTC ( [id://541151]=note: print w/replies, xml ) | Need Help?? |
Another useful use of list context is with regular expression captures. Consider:
and
The first example will set $x to 1 if $_ contains any alphanumerics. The second example sets $x to the first word. The second, list context, example is such a common, natural idiom to me that I never make the mistake of using captures in scalar context. I also almost never need to use $1, $2 etc. explicitly. --
In Section
Seekers of Perl Wisdom
|
|