Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re (tilly) 1: associative array problem

by CharlesClarkson (Curate)
on Nov 02, 2001 at 23:04 UTC ( #122886=note: print w/ replies, xml ) Need Help??


in reply to Re (tilly) 1: associative array problem
in thread associative array problem

To clarify that a bit, the program can be reduced to:

my %STUDQT; $STUDQT{11} = [qw/fname mname/]; $STUDQT{11}[1][2] = 0; #$STUDQT{12} = [qw/fname mname/]; $STUDQT{12}[1][2] = 0; print qq|\$STUDQT{11}[1][2] = $STUDQT{11}[1][2]\n|, qq|\t\$STUDQT{12}[1][2] = $STUDQT{12}[1][2]\n|; $STUDQT{11}[1][2] = 'hello'; #Problem print qq|\$STUDQT{11}[1][2] = $STUDQT{11}[1][2]\n|, qq|\t\$STUDQT{12}[1][2] = $STUDQT{12}[1][2]\n|; __END__
Don't use strict and run it as is:
$STUDQT{11}[1][2] = 0 $STUDQT{12}[1][2] = 0 $STUDQT{11}[1][2] = hello $STUDQT{12}[1][2] = 0
Just as we expect. But uncomment: #$STUDQT{12} =  [qw/fname mname/]; and we get:
$STUDQT{11}[1][2] = 0 $STUDQT{12}[1][2] = 0 $STUDQT{11}[1][2] = hello $STUDQT{12}[1][2] = hello

Turning on strict reveals that we are attempting to use 'mname' as a symbolic reference and perl guesses what we are attempting as tilly mentioned.

HTH,
Charles K. Clarkson


Comment on Re: Re (tilly) 1: associative array problem
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (14)
As of 2015-07-06 21:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (83 votes), past polls