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.19 by root, Mon Dec 1 13:47:09 2008 UTC vs.
Revision 1.23 by root, Wed Jul 1 08:25:04 2009 UTC

5 5
6use XSLoader; 6use XSLoader;
7use Scalar::Util; 7use Scalar::Util;
8 8
9BEGIN { 9BEGIN {
10 our $VERSION = '1.4'; 10 our $VERSION = '1.42';
11 XSLoader::load __PACKAGE__, $VERSION; 11 XSLoader::load __PACKAGE__, $VERSION;
12} 12}
13 13
14=head1 NAME 14=head1 NAME
15 15
88It is a bit convoluted to read, but basically it says that the value 88It is a bit convoluted to read, but basically it says that the value
89stored in C<$var> is referenced by: 89stored in C<$var> is referenced by:
90 90
91=over 4 91=over 4
92 92
93=item - in the lexical C<$closure_var> (0x8abcc8), which is inside an instantiated 93=item - the lexical C<$closure_var> (0x8abcc8), which is inside an instantiated
94closure, which in turn is used quite a bit. 94closure, which in turn is used quite a bit.
95 95
96=item - in the package-level lexical C<$global_my>. 96=item - the package-level lexical C<$global_my>.
97 97
98=item - in the global package variable named C<$Test::var>. 98=item - the global package variable named C<$Test::var>.
99 99
100=item - in the hash element C<ukukey2>, in the hash in the my variable 100=item - the hash element C<ukukey2>, in the hash in the my variable
101C<$testsub_local> in the sub C<Test::testsub> and also in the hash 101C<$testsub_local> in the sub C<Test::testsub> and also in the hash
102C<$referenced by Test::hash2>. 102C<$referenced by Test::hash2>.
103 103
104=item - in the hash element with key C<ukukey> in the hash stored in 104=item - the hash element with key C<ukukey> in the hash stored in
105C<%Test::hash>. 105C<%Test::hash>.
106 106
107=item - some anonymous mortalised reference on the stack (which is caused 107=item - some anonymous mortalised reference on the stack (which is caused
108by calling C<track> with the expression C<\$var>, which creates the 108by calling C<track> with the expression C<\$var>, which creates the
109reference). 109reference).
151 151
152 if ($depth) { 152 if ($depth) {
153 my (@about) = find $$refref; 153 my (@about) = find $$refref;
154 if (@about) { 154 if (@about) {
155 for my $about (@about) { 155 for my $about (@about) {
156 $about->[0] =~ s/([^\x20-\x7e])/sprintf "\\{%02x}", ord $1/ge;
156 $buf .= "$indent" . (@about > 1 ? "+- " : "") . $about->[0]; 157 $buf .= "$indent" . (@about > 1 ? "+- " : "") . $about->[0];
157 if (@$about > 1) { 158 if (@$about > 1) {
158 if ($seen{ref2ptr $about->[1]}++) { 159 if ($seen{ref2ptr $about->[1]}++) {
159 $buf .= " " . (_f $about->[1]) . ", which was seen before.\n"; 160 $buf .= " " . (_f $about->[1]) . ", which was seen before.\n";
160 } else { 161 } else {
172 $buf .= "$indent not referenced within the search depth.\n"; 173 $buf .= "$indent not referenced within the search depth.\n";
173 } 174 }
174 }; 175 };
175 176
176 $buf .= (_f $ref) . " is\n"; 177 $buf .= (_f $ref) . " is\n";
178
177 $track->(\$ref, $depth || $ENV{PERL_DEVEL_FINDREF_DEPTH} || 10, ""); 179 $track->(\$ref, $depth || $ENV{PERL_DEVEL_FINDREF_DEPTH} || 10, "");
178 $buf 180 $buf
179} 181}
180 182
181=item @references = Devel::FindRef::find $ref 183=item @references = Devel::FindRef::find $ref
191=cut 193=cut
192 194
193sub find($) { 195sub find($) {
194 my ($about, $excl) = &find_; 196 my ($about, $excl) = &find_;
195 my %excl = map +($_ => undef), @$excl; 197 my %excl = map +($_ => undef), @$excl;
196 grep !exists $excl{ref2ptr $_->[1]}, @$about 198 grep !($#$_ && exists $excl{ref2ptr $_->[1]}), @$about
197} 199}
198 200
199=item $ref = Devel::FindRef::ptr2ref $integer 201=item $ref = Devel::FindRef::ptr2ref $integer
200 202
201Sometimes you know (from debugging output) the address of a perl scalar 203Sometimes you know (from debugging output) the address of a perl scalar

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines