in reply to NEWBIE Brain Teaser #2, by nysus
This was a good exercise. My biggest hurdle was figuring out why $_ held the value 2 and @_ contained qw(nothing nothing) rather than qw(alpha omega). After a bit of searching I think I found the answer.
I tracked down information on the qw operator and found this in the perlop manpage:
qw// is exactly equivalent to split(' ', q/STRING/); This equivalency means that if used in scalar context, you'll get split's (unfortunate) scalar context behavior...
So read the documentation on split and found:
If not in list context, returns the number of fields found and splits into the @_ array.
So is that pretty much answer? Is there any more magic to it?
|
---|
Replies are listed 'Best First'. | |
---|---|
qw// in Perl 5.6
by Eureka_sg (Monk) on Apr 16, 2001 at 07:26 UTC | |
by nysus (Parson) on Apr 16, 2001 at 15:12 UTC |
In Section
Seekers of Perl Wisdom