view release on metacpan or search on metacpan
lib/lexical/underscore.pm view on Meta::CPAN
BEGIN {
$lexical::underscore::AUTHORITY = 'cpan:TOBYINK';
$lexical::underscore::VERSION = '0.004';
}
use if ($] >= 5.009 && $] < 5.023), PadWalker => qw( peek_my );
BEGIN {
*peek_my = sub { +{} } unless __PACKAGE__->can('peek_my');
}
sub lexical::underscore
lib/lexical/underscore.pm view on Meta::CPAN
returns the global C<< $_ >>.
=head2 Technical Details
The C<lexical::underscore> function returns a scalar reference to either a
lexical C<< $_ >> variable somewhere up the call stack (using L<PadWalker>
magic), or to the global C<< $_ >> if there was no lexical version.
Wrapping C<lexical::underscore> in C<< ${ ... } >> dereferences the scalar
reference, allowing you to access (and even assign to) it.
lib/lexical/underscore.pm view on Meta::CPAN
Please report any bugs to
L<http://rt.cpan.org/Dist/Display.html?Queue=lexical-underscore>.
=head1 SEE ALSO
L<PadWalker>.
=head1 AUTHOR
Toby Inkster E<lt>tobyink@cpan.orgE<gt>.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/lexicals.pm view on Meta::CPAN
use strict; use warnings;
package lexicals;
our $VERSION = '0.35';
use PadWalker;
use base 'Exporter';
our @EXPORT = qw(lexicals);
sub lexicals {
my $hash = PadWalker::peek_my(1);
return +{
map {
my $v = $hash->{$_};
$v = $$v if ref($v) =~ m'^(SCALAR|REF)$';
s/^[\$\@\%\*]//;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/opts.pm view on Meta::CPAN
package opts;
use strict;
use warnings;
our $VERSION = '0.08';
use Exporter 'import';
use PadWalker qw/var_name/;
use Getopt::Long;
use Carp ();
our @EXPORT = qw/opts/;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/B/Deparse.pm view on Meta::CPAN
=item *
Lexical (my) variables declared in scopes external to a subroutine
appear in coderef2text output text as package variables. This is a tricky
problem, as perl has no native facility for referring to a lexical variable
defined within a different scope, although L<PadWalker> is a good start.
See also L<Data::Dump::Streamer>, which combines B::Deparse and
L<PadWalker> to serialize closures properly.
=item *
There are probably many more bugs on non-ASCII platforms (EBCDIC).
view all matches for this distribution
view release on metacpan or search on metacpan
next CMD;
};
=head4 C<y> - List lexicals in higher scope
Uses C<PadWalker> to find the lexicals supplied as arguments in a scope
above the current one and then displays then using C<dumpvar.pl>.
=cut
$cmd =~ /^y(?:\s+(\d*)\s*(.*))?$/ && do {
# See if we've got the necessary support.
eval { require PadWalker; PadWalker->VERSION(0.08) }
or &warn(
$@ =~ /locate/
? <<EOM
PadWalker module not found - please install; try the command
perl -MCPAN -e "install PadWalker"
EOM
: $@
)
and next CMD;
# Got all the modules we need. Find them and print them.
my @vars = split (' ', $2 || '');
# Find the pad.
my $h = eval { PadWalker::peek_my(($1 || 0) + 1) };
# Oops. Can't find it.
$@ and $@ =~ s/ at .*//, &warn($@), next CMD;
# Show the desired vars with dumplex().
B<m> I<expr> Evals expression in list context, prints methods callable
on the first element of the result.
B<m> I<class> Prints methods callable via the given class.
B<M> Show versions of loaded modules.
B<y> [I<n> [I<Vars>]] List lexicals in higher scope <n>. Vars same as B<V>.
Requires the module B<PadWalker>.
B<<> ? List Perl commands to run before each prompt.
B<<> I<expr> Define Perl command to run before each prompt.
B<<<> I<expr> Add to the list of Perl commands to run before each prompt.
B<< *> Delete the list of perl commands to run before each prompt.
B<>> ? List Perl commands to run after each prompt.
view all matches for this distribution
view release on metacpan or search on metacpan
# perl(IO/Socket.pm) at line 1560
# perl(Carp.pm) at line 7338 (builtin SKIP)
# perl(Term/ReadLine.pm) at line 5725 inside eval (SKIP)
# perl(Config.pm) at line 7633
# perl(dumpvar.pl) at line 2222
# perl(PadWalker.pm) >= 0.080 at line 2409 inside eval (SKIP)
# perl(dumpvar.pl) at line 2418
# perl(dumpvar.pl) at line 5316
# perl(Class/ISA.pm) at line 4576 inside eval (SKIP)
# perl(Carp.pm) at line 7278 (builtin SKIP)
# perl(Devel/Peek.pm) at line 7487 inside eval (SKIP)
view all matches for this distribution
view release on metacpan or search on metacpan
},
"runtime" : {
"requires" : {
"B::Hooks::Parser" : "0.21",
"B::OPCheck" : "0.27",
"PadWalker" : "1.93",
"Sub::Exporter" : "0"
}
}
},
"release_status" : "stable",
view all matches for this distribution