John W. Krahn wrote:
for (my $i = 0; $i < @arry; $i++) {
    splice (@arry, $i, 1, split (' ', $arry[$i], 1));
}

How does that populate the @new_array variable?

Mine doesn't populate @new_array. It takes the original array and replaces it with the equivalent of everyone else's @new_array :-)
(Or at least it's supposed to.)

"split(' ', $arry[$i], 1)" is
exactly the same as "$arry[$i]" so you are replacing each element of the array
with itself.  (A limit of 1 passes the string through unchanged.)

It's not my fault, blame mail client. When /I/ sent it, it said:

for (my $i = 0; $i < @arry; $i++) {
    splice (@arry, $i, 1, split (' ', $arry[$i], 2));
}

with the "2", not the "1" ;-)

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to