… | |
… | |
104 | |
104 | |
105 | =cut |
105 | =cut |
106 | |
106 | |
107 | sub find($); |
107 | sub find($); |
108 | |
108 | |
|
|
109 | sub _f($) { |
|
|
110 | "$_[0] [refcount " . (_refcnt $_[0]) . "]" |
|
|
111 | } |
|
|
112 | |
109 | sub track { |
113 | sub 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 | |
194 | Marc Lehmann <pcg@goof.com>. |
198 | Marc Lehmann <pcg@goof.com>. |
195 | |
199 | |
196 | =head1 BUGS |
|
|
197 | |
|
|
198 | Only code values, arrays, hashes, scalars and magic are being looked at. |
|
|
199 | |
|
|
200 | This is a quick hack only. |
|
|
201 | |
|
|
202 | =head1 COPYRIGHT AND LICENSE |
200 | =head1 COPYRIGHT AND LICENSE |
203 | |
201 | |
204 | Copyright (C) 2007 by Marc Lehmann. |
202 | Copyright (C) 2007, 2008 by Marc Lehmann. |
205 | |
203 | |
206 | This library is free software; you can redistribute it and/or modify |
204 | This library is free software; you can redistribute it and/or modify |
207 | it under the same terms as Perl itself, either Perl version 5.8.8 or, |
205 | it under the same terms as Perl itself, either Perl version 5.8.8 or, |
208 | at your option, any later version of Perl 5 you may have available. |
206 | at your option, any later version of Perl 5 you may have available. |
209 | |
207 | |