in reply to Re^2: Reading session data
in thread Reading session data
Is there any situation where the 'old' syntax is preferable or even required?
It is not required for hashrefs like this but obviously you can't use the normal arrow to dereference things where there are no components. So, if you have a scalar reference the only ways to dereference that are with a $$ or using postfix dereference. In such situations I much prefer the $$ for clarity. In fact I've just tried this example to illustrate and it won't even compile with the postfix deref line uncommented (error is $* is no longer supported as of Perl 5.30).
#!/usr/bin/env perl use strict; use warnings; use feature 'say'; my $foo = 'some string'; my $ref = \$foo; say "Deref with \$\$: $$ref"; # Uncomment next line for compilation error - why? #say "Postfix deref: $ref->$*";
Perhaps someone who likes/uses postfix deref can explain where the compilation error comes from and how to fix it. As for me, I'm quite happy with $$ in these situations.
See also I use postfix dereferencing ... for various comments on how wonderful/terrible postfix dereferencing is.
🦛
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Reading session data
by kcott (Archbishop) on Jul 01, 2023 at 13:25 UTC | |
by hippo (Archbishop) on Jul 01, 2023 at 14:29 UTC |