cs202083 has asked for the wisdom of the Perl Monks concerning the following question:

I start to REALLY love the site, few seconds save me hours. thanks alot to Happy-the-monk and Sören !! Re: problem with perl "for" loop by esskar on Mar 11, 2004 at 18:08 GMT+5 well, your loop iterates one too much. Fix: for($left = 0; $left < $#hold; $left++) { if($hold$left == $hold$left+1) { return 0; } } reply d/l code Re: problem with perl "for" loop by Happy-the-monk on Mar 11, 2004 at 18:09 GMT+5 It's a warning, not an error. $hold$left+1 will eventually become bigger than the index of the array's last element. Sören

Replies are listed 'Best First'.
Re: problem with perl "for" loop
by esskar (Deacon) on Mar 11, 2004 at 23:08 UTC
    well, your loop iterates one too much.
    Fix:
    for($left = 0; $left < $#hold; $left++) { if($hold[$left] == $hold[$left+1]) { return 0; } }
Re: problem with perl "for" loop
by Happy-the-monk (Canon) on Mar 11, 2004 at 23:09 UTC
    It's a warning, not an error.
    $hold[$left+1]   will eventually become bigger than the index of the array's last element.

    Sören