Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Counting the number of items returned by split without using a named arrayby BrowserUk (Patriarch) |
on May 03, 2006 at 10:16 UTC ( [id://547107]=note: print w/replies, xml ) | Need Help?? |
Another way that avoids a named array.
Also, split /\s+/ is the similar to as the slightly magical split ' ', except undefs from leading whitespace are suppressed. In turn, split ' ' is the same as split with no arguments, so you could reduce your code to:
If you don't have leading whitespace, or don't want to count the undef any leading whitespace would produce as an entry. Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
In Section
Seekers of Perl Wisdom
|
|