Hallo folks,

I don't understand the problem in the code snippet below. I am not able to
fetch the value of a specific array element $result[$i], WHY?

    :
    :
    :
    # LOGFILE already opened before

    my $noofbuilds = 5;
    my @results    = (0,1,1,1,0,1,1,0);
    my $average    = 0;
    my $sum        = 0;

    $debug && print LOGFILE '@results'." = @results\n";
# output: 0 1 1 1 0 1 1 0

    for( my $i=0 ; ( ( not undef $results[$i] ) && ( $i<$noofbuilds ) ) ;
$i++ )
    {
>>>>  $sum += $results[$i];
        $debug && print LOGFILE '$i'." = $i\n";
# output : correct $i
>>>>  $debug && print LOGFILE '$results[$i] = ' . $results[$i] ."\n";
# output : "$results[$i]  = " ???
        $debug && print LOGFILE '$sum'." = $sum\n";
# output : "$sum = 0"
    }
    $average = sprintf ("%3.1f", ( $sum / $noofbuilds ) );
    $debug && print LOGFILE '$average = $sum / $noofbuilds = ' . "$sum \/
$noofbuilds = $average\n";
    # output : "$average = $sum / $noofbuilds = 0 / 5 = 0"   # :o(
    :
    :
    :

Accessing array element via foreach is running, but I want to use the loop
mentioned above.

PLEASE HELP!

> Adios
>    Ralf

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to