in reply to Re^2: Reading session data
in thread Reading session data
G'day Bod,
It hadn't occurred to me when reading earlier posts referring to "old syntax", but your use of "modern syntax" made me wonder how much older $$hashref{key} was compared to $hashref->{key}.
The oldest Perl version available via the online "Perldoc Browser" is for "Perl 5.005". Poking around in various parts of that (perlop, perldsc, and others) I see both forms being used without any mention of one being newer. I'm happy to be proven wrong, but I rather suspect that both have been available since Perl 5.000.
Without the arrow (dereferencing) operator, it's easy to make mistakes, especially with complex data structures. This is discussed in "5.005: perlref: Using References"; this information is retained in "5.36.1: perlref: Using References".
Except in the simplest of cases, I'll always prefer the $hashref->{key} form, as I find it both easier to read and less error-prone. I can't think of any situation where the $$hashref{key} form is "required".
In closing, it's probably worth noting "Postfix Dereference Syntax" and "Postfix Reference Slicing". These are newer syntaxes. I prefer them; I acknowledge that others don't. There's an example of the former in my reply to the OP.
— Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Reading session data
by hippo (Archbishop) on Jul 01, 2023 at 09:19 UTC |