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 ...
Or, you can
teach him to fish and feed him for a lifetime

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
    In line 19 you use the m// operator, since you used m!! you don't have to escape the: / it defeats the whole purpose.
    m!PATTERN/PATTERN!; # will work fine.
    also the same goes for line 22
    if m!PATTERN/PATTERN!;


    -tengo mas que aprender