view release on metacpan or search on metacpan
lib/Zydeco.pm view on Meta::CPAN
$sig =~ s/^=\Q$ws$default//xs;
$sig =~ s/^((?&PerlOWS)) $GRAMMAR//xso;
if ($default =~ / \$ (?: class|self) /xso) {
require PadWalker;
$default = sprintf('do { my $invocants = PadWalker::peek_my(2)->{q[@invocants]}||PadWalker::peek_my(1)->{q[@invocants]}; my $self=$invocants->[-1]; my $class=ref($self)||$self; %s }', $default);
$parsed[-1]{default} = $default;
}
}
if ($sig) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/autobox/Bless.pm view on Meta::CPAN
use Scalar::Util;
use Devel::Peek;
use Carp;
use Devel::Caller 'caller_cv'; # cx_type is 40 not CXt_SUB unless it's the current version
# use PadWalker;
# use B;
# could take one of three approaches; remember every field seen in every class; remember the top n closest matches as we go; take the first good match
# it's a memory vs accuracy tradeoff
# could also take a hybrid approach and if we don't find an exact match, look for a best match
view all matches for this distribution
view release on metacpan or search on metacpan
lib/autobox/Closure/Attributes.pm view on Meta::CPAN
sub import {
shift->SUPER::import(CODE => 'autobox::Closure::Attributes::Methods');
}
package autobox::Closure::Attributes::Methods;
use PadWalker;
sub AUTOLOAD {
my $code = shift;
(my $attr = our $AUTOLOAD) =~ s/.*:://;
# we want the scalar unless the method name already a sigil
$attr = "\$$attr" unless $attr =~ /^[\$\@\%\&\*]/;
my $closed_over = PadWalker::closed_over($code);
exists $closed_over->{$attr}
or Carp::croak "$code does not close over $attr";
my $ref = ref $closed_over->{$attr};
lib/autobox/Closure/Attributes.pm view on Meta::CPAN
Go ahead and read the source code of this, it's not very long.
L<autobox> lets you call methods on coderefs (or any other scalar).
L<PadWalker> will let you see and change the closed-over variables of a coderef
.
L<AUTOLOAD|perlsub/"Autoloading"> is really just an accessor. It's just harder
to manipulate the "attributes" of a closure-based object than it is for
hash-based objects.
lib/autobox/Closure/Attributes.pm view on Meta::CPAN
Shawn M Moore, C<sartak@gmail.com>
=head1 SEE ALSO
L<autobox>, L<PadWalker>
The L</DESCRIPTION> section is from Anton van Straaten: L<http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg03277.html>
=head1 BUGS
view all matches for this distribution
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