in reply to 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?
When assigning to a list, if LIMIT is omitted, Perl supplies a LIMIT one larger than the number of variables in the list, to avoid unnecessary work.
Using ()= you request 0 fields, so in scalar context, you get 1.
→print my $n = () = split /-/, 'a-b-c';
1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: How to get the number of fields found by split without a warning?
by PodMaster (Abbot) on Dec 08, 2003 at 21:28 UTC | |
by bart (Canon) on Dec 08, 2003 at 21:36 UTC |