in reply to Re: Re: How to get the number of fields found by split without a warning?
in thread How to get the number of fields found by split without a warning?

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