Devel:...exicals(3pm)
β¨ NAME β¨
Devel::StackTrace::WithLexicals β it's literally Devel::StackTrace plus PadWalker, bestie π
π SYNOPSIS π
use Devel::StackTrace::WithLexicals;
sub process_user {
my $item_count = 20;
price_items();
print "$item_count\n"; # prints 21
}
sub price_items {
my $trace = Devel::StackTrace::WithLexicals->new(
unsafe_ref_capture => 1 # warning: can cause memory leak
);
while ( my $frame = $trace->next_frame() ) {
my $item_count_ref = $frame->lexical('$item_count');
${$item_count_ref}++ if ref $item_count_ref eq 'SCALAR';
}
}
process_user();
(yes she really does print 21, and yes that's the whole point π)
π¦ DESCRIPTION π¦
Okay so. Story time. πΈ
Devel::StackTrace is pretty good at generating stack traces. Iconic. No notes.
PadWalker is pretty good at the inspection and modification of your callers' lexical variables. Also iconic.
Devel::StackTrace::WithLexicals is pretty good at generating stack traces with all your callers' lexical variables. It's giving collab of the century, fr fr. Two icons, one module. π
π METHODS π
Every single method is the same as Devel::StackTrace β literally all of them, no cap. EXCEPT that frames (in class Devel::StackTrace::WithLexicals::Frame, iykyk) also have a lexicals method. β¨
That lexicals method returns the same hashref as returned by PadWalker. Same one. Identical.
BUT β and listen closely bestie β unless the unsafe_ref_capture option to Devel::StackTrace is used, then each reference is stringified. That can be useful to avoid leaking memory. π«Ά
Simple, really. πβοΈ
π AUTHOR π
Shawn M Moore, sartak@gmail.com
π BUGS π
Not me having to copy and paste some code from Devel::StackTrace to achieve this π (it's hard to subclass, okay??). There may be bugs lingering here. π
Lowkey a warning. Highkey also a confession.
π COPYRIGHT AND LICENSE π
Copyright 2008-2009 Shawn M Moore.
Some portions written by Dave Rolsky, they belong to him.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.36.0, dated 2022-10-14, page Devel:...exicals(3pm) β that's the whole vibe check, bestie, slay, periodt, go write some stack traces with lexicals ππ¦β¨
π¦ where this page comes from
- ubuntu noble: libdevel-stacktrace-withlexicals-perl 2.01-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdevel-stacktrace-withlexicals-perl 2.01-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdevel-stacktrace-withlexicals-perl 2.01-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms