Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re^3: Pushing hash ref onto array refby kcott (Archbishop) |
on Apr 12, 2021 at 10:58 UTC ( [id://11131131]=note: print w/replies, xml ) | Need Help?? |
I've been making a point of using "perlref: Postfix Dereference Syntax". It removes the need for nested braces and brackets (e.g. %{$aref->[$i]} and @{$href->{$key}}) which can be confusing. It also reads linearly; i.e. ref->deref_to (e.g. $ref->%*) vs. deref_to{ref}. For very simple dereferencing, I often find myself using the older (original) syntax (e.g. $$scalarref). This is no doubt out of years of habit and muscle memory. I still think $scalarref->$* is clearer and I try to remember to use that; it also adds consistency to my code. I also find "perlref: Postfix Reference Slicing" to be a lot clearer; especially when the initial reference is a complex variable itself. Of course, that all requires a sufficiently new version of Perl. For instance, I can't use that for $work where I'm constrained to 5.16; for personal code, where I'm using the latest Perl (currently 5.32) that's not an issue. — Ken
In Section
Seekers of Perl Wisdom
|
|