Returns the length in characters of the value of EXPR. If EXPR is omitted, returns length of $_. Note that this cannot be used on an entire array or hash to find out how many elements these have. For that, use scalar @array and scalar keys %hash respectively.
So when you are doing
I think you mean (the scalar function being optional in this case):$restLength = length(@rest);
$restLength = scalar @rest;
On another note there is not need to go through all the contortion of making your loop c-like. Something like:
will work just as well, and relieve you of worrying about iterators.for my $item (@rest) { print "$item": }
update: I neglected to mention that your split is working fine, but that it was the length bit that was causing what you were observing.
-enlil
In reply to Re: Basic question about split
by Enlil
in thread basic question on split
by Vince75
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |