Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: Use of uninitialized value

by cjb (Friar)
on Nov 23, 2010 at 11:41 UTC ( [id://873185]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://873185]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-24 05:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found