in reply to Re^2: Use of uninitialized value
in thread Use of uninitialized value

my $numerator; my $denominator; if ($indicator eq "SH"){ $numerator = $last_element; } elsif ($indicator eq "SL"){ $denominator = $last_element; } else { print "\nError: There has been an unexpected string within + the second to last element of the array\n"; }
You only ever initialise $numerator or $denominator on the first run through. Something like
my $numerator = 0; my $denominator = 0;
might work, if 0 is a suitable default value for you.

Replies are listed 'Best First'.
Re^4: Use of uninitialized value
by Anonymous Monk on Nov 23, 2010 at 11:59 UTC
    No, it's initialized to undef in every iteration of the loop.

      You're right, my bad. strike time it is then.