B::LexInfo

B::LexInfo is a Perl module that shows information about subroutine lexical variables.
Download

B::LexInfo Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Doug MacEachern
  • Publisher web site:
  • http://search.cpan.org/~gozer/mod_perl-1.30/lib/Apache/Status.pm

B::LexInfo Tags


B::LexInfo Description

B::LexInfo is a Perl module that shows information about subroutine lexical variables. B::LexInfo is a Perl module that shows information about subroutine lexical variables.SYNOPSIS use B::ShowLex (); my $lexi = B::ShowLex->new;Perl stores lexical variable names and values inside a padlist within the subroutine. Certain lexicals will maintain certain attributes after the the variable "goes out of scope". For example, when a scalar is assigned a string value, this value remains after the variable has gone out of scope, but is overridden the next time it is assigned to. Lexical Arrays and Hashes will retain their storage space for the maximum number of entries stored at any given point in time.This module provides methods to record this information, which can be dumped out as-is or to compare two "snapshots". The information learned from these snapshots can be valuable in a number of ways.METHODSMnewCreate a new B::LexInfo object: my $lexi = B::LexInfo->new;cvlexinfoCreate a padlist snapshot from a single subroutine: my $info = $lexi->cvlexinfo('Foo::bar');stash_cvlexinfoCreate a list of padlist snapshots for each subroutine in the given package: my $info = $lexi->stash_cvlexinfo('Foo');dumperReturn a reference to a stringified padlist snapshot: print ${ $lexi->dumper($info) }diffCompare two padlist snapshots and return the difference: my $before = $lexi->stash_cvlexinfo(__PACKAGE__); ... let some code run my $after = $lexi->stash_cvlexinfo(__PACKAGE__); my $diff = B::LexInfo->diff($before, $after); print $$diff;NOTE: This function relies on the diff -u command. You might need to configure $B::LexInfo::TmpDir and/or $B::LexInfo::DiffCmd to values other than the defaults in LexInfo.pm.cvrundiffTake a padlist snapshot of a subroutine, run the subroutine with the given arguments, take another snapshot and return a diff of the snapshots. my $diff = $lexi->cvrundiff('Foo::bar', "arg1", $arg2); print $$diff;Complete example: package Foo; use B::LexInfo (); sub bar { my($string) = @_; } my $lexi = B::LexInfo->new; my $diff = $lexi->cvrundiff('Foo::bar', "a string"); print $$diff;Produces: --- /tmp/B_LexInfo_1848.before Mon Jun 28 19:48:41 1999 +++ /tmp/B_LexInfo_1848.after Mon Jun 28 19:48:41 1999 @@ -2,8 +2,10 @@ { 'Foo::bar' => { '$string' => { - 'TYPE' => 'NULL', - 'NULL' => '0x80efd58' + 'TYPE' => 'PV', + 'LEN' => 9, + 'PV' => 'a string', + 'CUR' => 8 }, '__SPECIAL__1' => { 'TYPE' => 'NULL',Requirements:· Perl Requirements: · Perl


B::LexInfo Related Software