in reply to Help with a n Use of uninitialized value in join error message
derby is right, in that you normally wouldn't want to hard-code the termination value of a loop that iterates over an array (i.e., use $#ips rather than 15).
Also, be aware that the C idiom:
for ($x = 0; $x < @ips; $x++) {or:
for ($x = 0; $x <= $#ips; $x++) {is frequently coded in Perl as this:
for my $x (0..$#ips) {in cases where the loop index, $x is needed within the loop. Otherwise, when it isn't really necessary (as in your case), you'll frequently see derby's suggestion used or perhaps this variation which avoids use of the implicit $_:
for my $ip (@ips) { push @newips, $ip->[0]; push @attempts, $ip->[1]; }
dmm
You can give a man a fish and feed him for a day ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help with a n Use of uninitialized value in join error message
by s0ttle (Scribe) on Dec 29, 2001 at 00:49 UTC |