|
|
|
|
|
by draegtun
186 days ago
|
|
Yes (de)referencing can be a PITA sometimes but you've probably forgotten that your example code could have been better written like this: $hash1->{key1}{key2}
And if `hash1` was a hash (instead of a hashref) then it's just this: $hash1{key1}{key2}
The `%{}` de-reference you mention later is only when you have an operation that requires a hash, for eg: keys %{$hash1{key1}}
And for kstrauser example later in Python... hash1["hash_name"]["array_name"][3]
the equivalent in Perl would be... $hash1{hash_name}{array_name}[3]
I find having {} & [] as lookup keys for their types is not only more explicit but also safer/correct. |
|