Hello fionbarr,
Suppose you were silly unfortunate enough to have code like this:
2:56 >perl -wE "my %h = ( A => 'B' ); my $h = { A => 'C' }; say $h{A} +; say $$h{A}; say $h->{A};" B C C 3:15 >
That is, two (separate, unrelated) hashes both called h: a hash named %h, and an unnamed hash accessible via the scalar reference $h. $h{A} and $$h{A} would then be quite different things, but they would look so similar that it would be only too easy to confuse them. In a case like this, the value of the dereference syntax $h->{A} becomes apparent: it makes the dereference operation visually distinctive, and so reduces the danger of confusion.
Anyway, those of use who came to Perl from C++ find the arrow dereference syntax comfortingly familiar; it just “looks right.” ;-)
But, as always, TMTOWTDI, and YMMV.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: dereference hash
by Athanasius
in thread dereference hash
by fionbarr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |