Anyway, my best suggestion, please don't use this deref-ref syntax for the sake of readability
Try something like the following ors or defs and you are free to chain even more than two operators and assign too.
sub ors :lvalue { $_ && return $_ for @_ ; return $_[-1]; } # define analogous &defs ors($x,$y,$z) = 42;
This could also be included in a module like List::Util (if really missing, compare any and all )¹
Regarding documentation: the perlop Doc for // also covers || and &&.
They talk at length about returning the scalar value of the first operand because of the Boolean test, this might be related.
FWIW, I was also experimenting with
sub lv(&) :lvalue { ${ \( $_[0]->() ) } } lv{ $a // $b } = 666;
But this doesn't work because I can't specify that the prototype & code-block is an lvalue too. ( Probably a posteriori???)
Finally I discovered what looks like a bug at least in 5.36 inside the debugger.
feature 'signatures' seems to be enabled by default when testing sub declarations inside a prompt of perl -de0
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
¹) I'm having a deja-vu right now, did we discuss this before?
In reply to Re: Logical/defined or as lvalue
by LanX
in thread Logical/defined or as lvalue
by jo37
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |