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.16 by root, Fri Sep 19 05:07:56 2008 UTC vs.
Revision 1.18 by root, Mon Dec 1 13:22:43 2008 UTC

104 104
105=cut 105=cut
106 106
107sub find($); 107sub find($);
108 108
109sub _f($) {
110 "$_[0] [refcount " . (_refcnt $_[0]) . "]"
111}
112
109sub track { 113sub track {
110 my ($ref, $depth) = @_; 114 my ($ref, $depth) = @_;
111 @_ = (); 115 @_ = ();
112 116
113 my $buf = ""; 117 my $buf = "";
123 if (@about) { 127 if (@about) {
124 for my $about (@about) { 128 for my $about (@about) {
125 $buf .= "$indent" . (@about > 1 ? "+- " : " ") . $about->[0]; 129 $buf .= "$indent" . (@about > 1 ? "+- " : " ") . $about->[0];
126 if (@$about > 1) { 130 if (@$about > 1) {
127 if ($seen{ref2ptr $about->[1]}++) { 131 if ($seen{ref2ptr $about->[1]}++) {
128 $buf .= " $about->[1], which was seen before.\n"; 132 $buf .= " " . (_f $about->[1]) . ", which was seen before.\n";
129 } else { 133 } else {
130 $buf .= " $about->[1], which is\n"; 134 $buf .= " " . (_f $about->[1]) . ", which is\n";
131 $track->(\$about->[1], $depth - 1, $about == $about[-1] ? "$indent " : "$indent| "); 135 $track->(\$about->[1], $depth - 1, $about == $about[-1] ? "$indent " : "$indent| ");
132 } 136 }
133 } else { 137 } else {
134 $buf .= ".\n"; 138 $buf .= ".\n";
135 } 139 }
140 } else { 144 } else {
141 $buf .= "$indent not referenced within the search depth.\n"; 145 $buf .= "$indent not referenced within the search depth.\n";
142 } 146 }
143 }; 147 };
144 148
145 $buf .= "$ref is\n"; 149 $buf .= (_f $ref) . " is\n";
146 $track->(\$ref, $depth || $ENV{PERL_DEVEL_FINDREF_DEPTH} || 10, ""); 150 $track->(\$ref, $depth || $ENV{PERL_DEVEL_FINDREF_DEPTH} || 10, "");
147 $buf 151 $buf
148} 152}
149 153
150=item @references = Devel::FindRef::find $ref 154=item @references = Devel::FindRef::find $ref
191 195
192=head1 AUTHOR 196=head1 AUTHOR
193 197
194Marc Lehmann <pcg@goof.com>. 198Marc Lehmann <pcg@goof.com>.
195 199
196=head1 BUGS
197
198Only code values, arrays, hashes, scalars and magic are being looked at.
199
200This is a quick hack only.
201
202=head1 COPYRIGHT AND LICENSE 200=head1 COPYRIGHT AND LICENSE
203 201
204Copyright (C) 2007 by Marc Lehmann. 202Copyright (C) 2007, 2008 by Marc Lehmann.
205 203
206This library is free software; you can redistribute it and/or modify 204This library is free software; you can redistribute it and/or modify
207it under the same terms as Perl itself, either Perl version 5.8.8 or, 205it under the same terms as Perl itself, either Perl version 5.8.8 or,
208at your option, any later version of Perl 5 you may have available. 206at your option, any later version of Perl 5 you may have available.
209 207

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines