#!/usr/bin/perl -l use strict; use warnings; use PadWalker ":all"; sub foo { my $x; for ($x) { my $x; bar(\$_); } } sub bar { print var_name(1, $_[0]); # works my $vars = peek_my(1); print grep $vars->{$_} == $_[0], keys %$vars; # doesn't work unle +ss 2nd my $x is commented out } foo();
In reply to Re^2: get name of lexical variable
by ysth
in thread get name of lexical variable
by khwilliamson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |