Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: find real length of an array

by Aristotle (Chancellor)
on Mar 16, 2003 at 19:04 UTC ( [id://243506]=note: print w/replies, xml ) Need Help??


in reply to Re: •Re: find real length of an array
in thread find real length of an array

This has nothing to do with array behaviour in general, but solely with the way split behaves. Note that if you really want to conserve all trailing fields, instead of passing 99999, you should give it -1. This is documented in perlfunc:
If LIMIT is specified and positive, splits into no more than that many fields (though it may split into fewer). If LIMIT is unspecified or zero, trailing null fields are stripped (which potential users of pop would do well to remember). If LIMIT is negative, it is treated as if an arbitrarily large LIMIT had been specified.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re^3: find real length of an array
by hackmare (Pilgrim) on Mar 16, 2003 at 22:37 UTC

    Aristotle,

    Thanks for the '-1' pointer. I wasn't aware of it.

    I still have to check my coriginal code because with it I am splitting with a large limit value but am still having the issue of misrepresented array size for arrays generated by split. I will look into my code this AM and report back to the monks to clarify what I find to be the source (programmer -me- error or odd behaviour).

    Clearly probabilities lean towards the former.

    hackmare.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-24 01:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found