On Thu, 23 Mar 2006 12:05:07 -0800, you wrote:

>This is probably a fun trivial question: I'd like to count the number of 
>words in a string. My command:
>my $count = split(/\s+/,$line);
>
>works. But Perl complains about:
>Use of implicit split to @_ is deprecated
>
>It works, but it's deprecated. I can assign split to an array, then do a 
>scalar() on it. But this cannot be the best method (too much work!).
>
>Your take guys?

This works, but it strikes me as a bit *too* clever:

my $count = () = split(/\s+/, $line, -1);

If you've forgotten, a negative third argument forces split to produce
all of the possible fields, keeping trailing null fields. In particular,
it ignores the size of the destination list. I've more often seen this
empty list idiom in conjunction with m//g--not that it's tremendously
common there, either.
-- 
Eric Amick
Columbia, MD
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to