in reply to basic question on split
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Basic question about split
by jweed (Chaplain) on Dec 13, 2003 at 02:12 UTC |