in reply to is split optimized?
Does split only find the first chunk when you only ask for the first chunk? No. Since you are calling split in a list context, it generates a list of all elements and assigns that to your list.
You were very careful to call split in list context, BTW. In your example, $y does not have to be in parentheses, because your right-side construct puts split in list context. Both <nobr>($y) = split()</nobr> and <nobr>$y = (split())[0]</nobr> call split in list context. You don't need both, but it certainly works as you have it.
BTW, Seekers of Perl Wisdom is the right place to ask this kind of question.
Russ
Brainbench 'Most Valuable Professional' for Perl
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Calling split in a scalar context
by gryng (Hermit) on Jul 14, 2000 at 06:27 UTC |