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

Re: Relative Merits of References

by ikegami (Patriarch)
on May 11, 2006 at 14:33 UTC ( [id://548725]=note: print w/replies, xml ) Need Help??


in reply to Relative Merits of References

I see some differences.
  • my $h = {'name' => 'value', ...};
    creates two variables (a hash and a reference to it), while
    my %h = ('name' => 'value', ...);
    creates only the hash.

  • my $h = {'name' => 'value', ...};
    requires dereferencing to access the hash, while you might need to create references to
    my %h = ('name' => 'value', ...);
    to use it.

  • It is less obvious in
    my $h = {'name' => 'value', ...};
    than in
    my %h = ('name' => 'value', ...);
    that was are dealing with a hash because the hash sigil is not used in the former.

  • However, all of the above are rather inconsequential. The real difference is that it would have been much less work to switch to
    my $h = {'name' => 'value', ...};
    rather than to
    my %h = ('name' => 'value', ...);
    since the rest of the code was expecting a reference to a hash.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2024-04-23 12:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found