Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: can't use string as hash ref

by Anonymous Monk
on Oct 25, 2010 at 12:30 UTC ( [id://867207]=note: print w/replies, xml ) Need Help??


in reply to Re: can't use string as hash ref
in thread can't use string as hash ref

# this will be ok $hash{1}{\@array}{1} = 42; #this will be ok $hash{1}{\@array}{1}{1} = 42;
The latter doesn't work either (it just doesn't issue an error here, 'cos the script is dying after the first problem on line 13).

The reason is simply that if you assign 42 to $hash{\@array}, or $hash{1}{\@array}{1} for that matter, and then try to deference that value in the next statement, you're essentially trying to say

"42"->{1} = 42
which obviously doesn't make sense.

Replies are listed 'Best First'.
Re^3: can't use string as hash ref
by spickles (Scribe) on Oct 25, 2010 at 15:46 UTC

    Thanks for all of the replies. It sounds like I have a dereferencing issue. I'm going to take another whack at it and post back. Each time I use hashes and think I've got it 'licked' ....

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2025-07-12 13:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.