Don't ask to ask, just ask | |
PerlMonks |
Re: Re: Returning first element of an array from a functionby dragonchild (Archbishop) |
on Mar 17, 2004 at 13:13 UTC ( [id://337315]=note: print w/replies, xml ) | Need Help?? |
Actually, don't forget it. It may not be an answer to the general case, but it is important to note that split (and a few others) may be able to improve on the general case. I would extend your answer as so:
This both avoids building the list that AnonyMonk so correctly pointed out above, plus gains the documentation benefits of using slicing. This isn't possible to do with all cases, but it is quite useful. ------
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
In Section
Seekers of Perl Wisdom
|
|