in reply to Is this a hash?
You've got a pile of answers already, but here's one more!
Here's a hash:
And here's a hashref, which is like the one that you had:my %hash = ( a => 1, b => 2 ); print $hash{'b'}; # prints 2
As you can see, you use percent and brackets to define a hash, and dollar and braces to define a hashref.my $hashref = { c => 3, d => 4 }; print $hashref->{c}; # prints 3
In addition, you can get a reference to something by putting a backslash in front of it ..
References are useful when you want to pass data structures around -- it's more efficient to pass a reference (that big thing over there) rather than the structure itself.my $ref_to_hash = \%hash; print $ref_to_hash->{'a'}; # prints 1
|
|---|