Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re: Re: Use of uninitialized value in array element

by Fastolfe (Vicar)
on Jul 12, 2002 at 22:27 UTC ( #181411=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Use of uninitialized value in array element
in thread Use of uninitialized value in array element

The presence of a dollar-sign is not the issue. The value of the variables at this point in the program is what's suspect:

my $a; # undef my $b = 1; my @array = ( [4, 3], [2, 1], ); print $array[$b]->[$b]; # 1 print $array[$b]->[$a]; # Use of uninitialized value in array element, + but prints 2 print $array[$a]->[$b]; # Use of uninitialized value in array element, + but prints 3
The undefined value has a numeric value of 0, so it all "works" because of Perl's DWIM nature, but through the grace of warnings we know that something is amiss if we expect that our index variables should always have a numeric value.


Comment on Re: Re: Re: Use of uninitialized value in array element
Download Code
Re: Re: Re: Re: Use of uninitialized value in array element
by TexasTess (Beadle) on Jul 14, 2002 at 19:12 UTC
    Thanks for the clarification, I had NOT Experienced this in any of my perl works....and as a result am doomed for perl monk dumbassdom....

    TexasTess
    "Great Spirits Often Encounter Violent Opposition From Mediocre Minds" --Albert Einstein

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2014-12-29 11:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (187 votes), past polls