Problems? Is your data what you think it is? | |
PerlMonks |
Re: Re: Re: How to get the number of fields found by split without a warning?by davido (Cardinal) |
on Dec 09, 2003 at 06:40 UTC ( [id://313373]=note: print w/replies, xml ) | Need Help?? |
I like Roger's my $qty = scalar ( split ',', $string ); method, however, it takes us back to where we started, by generating a warning message about implicit splitting into @_ being deprecated (if the code is tested under -w or use warnings;).
Unfortunately, the solution is either to turn off warnings for that section of code, or to revert back to the other solution which makes an extra copy: my $qty = @{[ split ',', $string ]};. Of course, if all you're trying to do it count commas except for trailing ones, you could probably just loop through the string instead.
Dave
In Section
Seekers of Perl Wisdom
|
|