Arunkumar_141 has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
when a hash is defined with a reference , it's value is obtained by dereferencing using ->. Here keys of hash is referencing to a hash. so while dereferencing, why is it allowing $hash->{a}{1} as it should allow only $hash->{a}->{1} $hash={a=>{1=>2}};
print "ref($hash->{a})"; #says its an hash reference print "$hash->{a}->{1}" ;#returns 2 as expected print "$hash->{a}{1}"; #also returns 2 ,my question is how without der +eferencing the key of $hash->{a} its value is getting displayed?
2019-03-07 Athanasius added paragraph and code tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Query on References
by holli (Abbot) on Mar 05, 2019 at 17:54 UTC | |
|
Re: Query on References
by tybalt89 (Monsignor) on Mar 05, 2019 at 18:31 UTC | |
|
Re: Query on References
by AnomalousMonk (Archbishop) on Mar 05, 2019 at 20:33 UTC | |
|
Re: Query on References
by thanos1983 (Parson) on Mar 05, 2019 at 17:51 UTC | |
|
Re: Query on References
by BillKSmith (Monsignor) on Mar 05, 2019 at 22:29 UTC |