ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Devel-FindRef/FindRef.pm
(Generate patch)

Comparing Devel-FindRef/FindRef.pm (file contents):
Revision 1.20 by root, Sat Dec 6 12:42:49 2008 UTC vs.
Revision 1.25 by root, Sun Aug 30 14:34:41 2009 UTC

1package Devel::FindRef; 1package Devel::FindRef;
2 2
3no warnings; # I hate warning nazis 3use common::sense;
4use strict;
5 4
6use XSLoader; 5use XSLoader;
7use Scalar::Util; 6use Scalar::Util;
8 7
9BEGIN { 8BEGIN {
10 our $VERSION = '1.4'; 9 our $VERSION = '1.422';
11 XSLoader::load __PACKAGE__, $VERSION; 10 XSLoader::load __PACKAGE__, $VERSION;
12} 11}
13 12
14=head1 NAME 13=head1 NAME
15 14
151 150
152 if ($depth) { 151 if ($depth) {
153 my (@about) = find $$refref; 152 my (@about) = find $$refref;
154 if (@about) { 153 if (@about) {
155 for my $about (@about) { 154 for my $about (@about) {
155 $about->[0] =~ s/([^\x20-\x7e])/sprintf "\\{%02x}", ord $1/ge;
156 $buf .= "$indent" . (@about > 1 ? "+- " : "") . $about->[0]; 156 $buf .= "$indent" . (@about > 1 ? "+- " : "") . $about->[0];
157 if (@$about > 1) { 157 if (@$about > 1) {
158 if ($seen{ref2ptr $about->[1]}++) { 158 if ($seen{ref2ptr $about->[1]}++) {
159 $buf .= " " . (_f $about->[1]) . ", which was seen before.\n"; 159 $buf .= " " . (_f $about->[1]) . ", which was seen before.\n";
160 } else { 160 } else {
172 $buf .= "$indent not referenced within the search depth.\n"; 172 $buf .= "$indent not referenced within the search depth.\n";
173 } 173 }
174 }; 174 };
175 175
176 $buf .= (_f $ref) . " is\n"; 176 $buf .= (_f $ref) . " is\n";
177
177 $track->(\$ref, $depth || $ENV{PERL_DEVEL_FINDREF_DEPTH} || 10, ""); 178 $track->(\$ref, $depth || $ENV{PERL_DEVEL_FINDREF_DEPTH} || 10, "");
178 $buf 179 $buf
179} 180}
180 181
181=item @references = Devel::FindRef::find $ref 182=item @references = Devel::FindRef::find $ref
191=cut 192=cut
192 193
193sub find($) { 194sub find($) {
194 my ($about, $excl) = &find_; 195 my ($about, $excl) = &find_;
195 my %excl = map +($_ => undef), @$excl; 196 my %excl = map +($_ => undef), @$excl;
196 grep !exists $excl{ref2ptr $_->[1]}, @$about 197 grep !($#$_ && exists $excl{ref2ptr $_->[1]}), @$about
197} 198}
198 199
199=item $ref = Devel::FindRef::ptr2ref $integer 200=item $ref = Devel::FindRef::ptr2ref $integer
200 201
201Sometimes you know (from debugging output) the address of a perl scalar 202Sometimes you know (from debugging output) the address of a perl scalar

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines