in reply to foreach nightmare!

my @well = split ('', $well); $highest = $well[0]; # definately problems here, cant pick out $ +well[0]
that should be okay. Why do you think there is a problem? Your problems are here:
for ($i = 0; $i < @well; $i++) { # scalar(@well) here if ($well[$i] > $highest) { $highest = $numbers[$i]; # $well[$i] here } }
You could also write your loop with:
foreach $number (@well) { $highest=$number if $highest<$number; }

Replies are listed 'Best First'.
Re: Re: foreach nightmare!
by chip (Curate) on May 08, 2003 at 16:14 UTC
    It's not necessary to change @well to scalar(@well), because the less-than operator imposes scalar contect on its operands already.

    But in any case, your foreach rewrite is much better. :-)

        -- Chip Salzenberg, Free-Floating Agent of Chaos