Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^4: Counting the number of items returned by split without using a named array

by salva (Canon)
on May 03, 2006 at 11:15 UTC ( #547122=note: print w/replies, xml ) Need Help??


in reply to Re^3: Counting the number of items returned by split without using a named array
in thread Counting the number of items returned by split without using a named array

may I push it as far as to dare to say that it is a bug?

well, probably not, as it is well documented on perlfunc

A workaround is to set the limit explicetly to undef (though, it generates a warning):

$count = () = split ' ', $_, undef;

amazingly, setting it to 0 doesn't work:

$ perl -MO=Deparse -e '$a = () = split(" ", $_, undef)' $a = () = split(" ", $_, undef); $ perl -MO=Deparse -e '$a = () = split(" ", $_, 0)' $a = () = split(" ", $_, 1);

A better workaround that doesn't generate warnings is to use a zero-but-true value:

$count = () = split ' ', $_, '0e0';
that is parsed as:
$ perl -MO=Deparse -e '$a = () = split(" ", $_, "0e0")' $a = () = split(" ", $_, '0e0');

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://547122]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2021-12-07 20:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (34 votes). Check out past polls.

    Notices?