Don't ask to ask, just ask | |
PerlMonks |
Re: why is $1 cleared at end of an inline sub?by LanX (Saint) |
on Sep 16, 2021 at 12:42 UTC ( [id://11136829]=note: print w/replies, xml ) | Need Help?? |
TL;DR all next time please condense it to the relevant part! > Seems a bit weird to have the end of a local sub clear '$1', yet that seems to be what is happening yes, easily shown in a SSCCE
> What was the logic of forcing/doing that? I'd say it's about localizing the inner sub to protect all caller levels from effects at a distance, consider
otherwise nobody could rely on $1 etc anymore after calling a random sub. Using a dedicated closure var holding the copied content of $1 is the way to go in your use case.
Cheers Rolf
In Section
Seekers of Perl Wisdom
|
|