LexAlias(3)
π¦ LexAlias(3) π¦
okay so this is the User Contributed Perl Documentation page for Devel::LexAlias, and it's a whole vibe: it aliases lexical variables. buckle up, bestie π«Ά
π NAME π
Devel::LexAlias β alias lexical variables. periodt.
β¨ SYNOPSIS β¨
use Devel::LexAlias qw(lexalias);
sub steal_my_x {
my $foo = 1;
lexalias(1, '$x', \$foo);
}
sub foo {
my $x = 22;
print $x; # prints 22
steal_my_x;
print $x; # prints 1
}
π DESCRIPTION π
Devel::LexAlias provides the ability to alias a lexical variable in a subroutine's scope to one of your choosing.
If you don't know why you'd want to do this, I'd suggest that you skip this module. If you think you have a use for it, I'd insist on it. π
Still here? iconic.
π«Ά lexalias( $where, $name, $variable )
$whereβ refers to the subroutine in which to alias the lexical, it can be a coderef or a call level such that you'd give tocaller$nameβ is the name of the lexical within that subroutine$variableβ is a reference to the variable to install at that location
π BUGS π
lexalias delves into the internals of the interpreter to perform its actions and is so very sensitive to bad data, which will likely result in flaming death, or a core dump. Consider this a warning. π₯π
There is no checking that you are attaching a suitable variable back into the pad as implied by the name of the variable, so it is possible to do the following:
lexalias( $sub, '$foo', [qw(an array)] );
The behaviour of this is untested, I imagine badness is very close on the horizon though. π
π SEE ALSO π
peek_subfromPadWalkerDevel::Peek
π AUTHOR π
Richard Clamp <richardc@unixbeard.net> with close reference to PadWalker by Robin Houston
π COPYRIGHT π
Copyright (c) 2002, 2013, Richard Clamp. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
and that's the whole page, bestie: manual page LexAlias(3), from perl v5.40.0, dated 2023-03-13, and yes it's the User Contributed Perl Documentation flavor. mwah πβ¨
π¦ where this page comes from
- epel 10: perl-Devel-LexAlias 0.05-32.el10_0 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms