local *_ = \$_[0];
On Thu, 06 May 2021 18:55:38 +0100, Rainer Weikusat wrote:
local *_ = \$_[0];
What witchcraft is that? I don't even know where to start looking it up.
... to the scalar the reference came from: Afterwards (while the local is in scope) $_ 'means' 'the scalar passed as first argument': It now has a
name but its contents weren't copied.
Rainer Weikusat <rweikusat@talktalk.net> writes:
# [1]
local *_ = \$_[0];
... to the scalar the reference came from: Afterwards (while the local is in >> scope) $_ 'means' 'the scalar passed as first argument': It now has a
name but its contents weren't copied.
I wonder how it compares to this alternative:
# [2]
local $_ = $_[0];
I guess [1] is aliasing and [2] is copying, although I'm not 100%
confident about this (nor the exact meaning of aliasing.)
It's documented in the "Symbol Tables" section of perlmod: *_ is the
typeglob whose scalar slot is $_
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 294 |
Nodes: | 16 (2 / 14) |
Uptime: | 243:55:01 |
Calls: | 6,626 |
Calls today: | 2 |
Files: | 12,175 |
Messages: | 5,320,318 |