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

Re: dereference syntax

by OM_Zen (Scribe)
on Feb 26, 2003 at 19:55 UTC ( #238893=note: print w/ replies, xml ) Need Help??


in reply to dereference syntax

Hi ,

# The $x is a hashreference and here : my $ones = {}; $ones{a}={b=>1}; print "[$ones{a}]\n"; print "[$ones->{a}]\n"; print "[$ones{a}->{b}]\n"; print "[$ones{a}{b}]\n"; __END__ [HASH(0xe01d8)] [] [1] [1]


$x->{a} is not the same as $x{a}

( $x->{a} will be a lookup of the key of a hashrefernce (the declaration in the above my $ones = {} kind of decalaration available ),

$x{a} will be a lookup of the key of %x)

$x{a}->{$b} is the same as $x{a}{$b}

Please read the perldoc perldsc for all kinds of data structure decalaration definition and access


Comment on Re: dereference syntax
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (13)
As of 2015-07-31 12:29 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 (277 votes), past polls