Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
devel:languages:perl:CPAN-P
perl-PadWalker
perl-PadWalker.spec
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File perl-PadWalker.spec of Package perl-PadWalker
# # spec file for package perl-PadWalker # # Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via https://bugs.opensuse.org/ # Name: perl-PadWalker Version: 2.5 Release: 0 %define cpan_name PadWalker Summary: Play with other peoples' lexical variables License: Artistic-1.0 OR GPL-1.0-or-later Group: Development/Libraries/Perl URL: https://metacpan.org/release/%{cpan_name} Source0: https://cpan.metacpan.org/authors/id/R/RO/ROBIN/%{cpan_name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: perl BuildRequires: perl-macros %{perl_requires} %description PadWalker is a module which allows you to inspect (and even change!) lexical variables in any subroutine which called you. It will only show those variables which are in scope at the point of the call. PadWalker is particularly useful for debugging. It's even used by Perl's built-in debugger. (It can also be used for evil, of course.) I wouldn't recommend using PadWalker directly in production code, but it's your call. Some of the modules that use PadWalker internally are certainly safe for and useful in production. * peek_my LEVEL * peek_our LEVEL The LEVEL argument is interpreted just like the argument to 'caller'. So 'peek_my(0)' returns a reference to a hash of all the 'my' variables that are currently in scope; 'peek_my(1)' returns a reference to a hash of all the 'my' variables that are in scope at the point where the current sub was called, and so on. 'peek_our' works in the same way, except that it lists the 'our' variables rather than the 'my' variables. The hash associates each variable name with a reference to its value. The variable names include the sigil, so the variable $x is represented by the string '$x'. For example: my $x = 12; my $h = peek_my (0); ${$h->{'$x'}}++; print $x; # prints 13 Or a more complex example: sub increment_my_x { my $h = peek_my (1); ${$h->{'$x'}}++; } my $x=5; increment_my_x; print $x; # prints 6 * peek_sub SUB The 'peek_sub' routine takes a coderef as its argument, and returns a hash of the 'my' variables used in that sub. The values will usually be undefined unless the sub is in use (i.e. in the call-chain) at the time. On the other hand: my $x = "Hello!"; my $r = peek_sub(sub {$x})->{'$x'}; print "$$r\n"; # prints 'Hello!' If the sub defines several 'my' variables with the same name, you'll get the last one. I don't know of any use for 'peek_sub' that isn't broken as a result of this, and it will probably be deprecated in a future version in favour of some alternative interface. * closed_over SUB 'closed_over' is similar to 'peek_sub', except that it only lists the 'my' variables which are used in the subroutine but defined outside: in other words, the variables which it closes over. This _does_ have reasonable uses: see Data::Dump::Streamer, for example (a future version of which may in fact use 'closed_over'). * set_closed_over SUB, HASH_REF 'set_closed_over' reassigns the pad variables that are closed over by the subroutine. The second argument is a hash of references, much like the one returned from 'closed_over'. * var_name LEVEL, VAR_REF * var_name SUB, VAR_REF 'var_name(sub, var_ref)' returns the name of the variable referred to by 'var_ref', provided it is a 'my' variable used in the sub. The 'sub' parameter can be either a CODE reference or a number. If it's a number, it's treated the same way as the argument to 'peek_my'. For example, my $foo; print var_name(0, \$foo); # prints '$foo' sub my_name { return var_name(1, shift); } print my_name(\$foo); # ditto %prep %setup -q -n %{cpan_name}-%{version} %build perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="%{optflags}" make %{?_smp_mflags} %check make test %install %perl_make_install %perl_process_packlist %perl_gen_filelist %files -f %{name}.files %defattr(-,root,root,755) %doc Changes README %changelog
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor