Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://122886]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2017-02-24 23:23 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (364 votes). Check out past polls.