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.
|