Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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.

Charles K. Clarkson

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://122886]
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: (2)
As of 2015-11-28 10:40 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (741 votes), past polls