Perl-Sensitive Sunglasses | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I can't see why you need to avoid using array indices at all.
First of all, you can get the start of the array index (of all arrays, actually) by using the special variable $[. The default value for this variable is 0. You are discouraged to modify this value in your script. Any change to this variable in other files (or packages? Not really sure about that one. See perlvar for more info. It's "files".) such as modules, will be visible in that file only. In short: I find it perfectly reasonable to always assume that the start index is 0 for your script. Always. Unless you, yourself, change it to something else. Second, the last index for an array @array is $#array. No, $#array is not always 1 less than scalar(@array), that depends on the value for $[; but it is always the last index of your array. In summary: it's perfectly 100% safe to write: but at least I wouldn't mind at all if you hardcoded a 0 for that $[. In reply to Re: Array indices
by bart
|
|