… | |
… | |
19 | use Devel::FindRef; |
19 | use Devel::FindRef; |
20 | |
20 | |
21 | =head1 DESCRIPTION |
21 | =head1 DESCRIPTION |
22 | |
22 | |
23 | Tracking down reference problems (e.g. you expect some object to be |
23 | Tracking down reference problems (e.g. you expect some object to be |
24 | destroyed, but there are still references to it that keep it alive). can |
24 | destroyed, but there are still references to it that keep it alive) can be |
25 | be very hard, although perl keeps track of all values. |
25 | very hard. Fortunately, perl keeps track of all its values, so tracking |
|
|
26 | references "backwards" is usually possible. |
26 | |
27 | |
27 | The C<track> function can hlep track down some of those refernces back to |
28 | The C<track> function can help track down some of those references back to |
28 | the variables containing them. |
29 | the variables containing them. |
29 | |
30 | |
30 | For example, for this fragment: |
31 | For example, for this fragment: |
31 | |
32 | |
32 | package Test; |
33 | package Test; |
… | |
… | |
41 | print Devel::FindRef::track \$var; |
42 | print Devel::FindRef::track \$var; |
42 | } |
43 | } |
43 | |
44 | |
44 | testsub; |
45 | testsub; |
45 | |
46 | |
46 | The output is as follows (or similar to htis, in case I forget to update |
47 | The output is as follows (or similar to this, in case I forget to update |
47 | the manpage afetr some changes): |
48 | the manpage after some changes): |
48 | |
49 | |
49 | SCALAR(0x676fa0) is |
50 | SCALAR(0x676fa0) is |
50 | referenced by REF(0x676fb0), which is |
51 | referenced by REF(0x676fb0), which is |
51 | in the lexical '$x' in CODE(0x676370), which is |
52 | in the lexical '$x' in CODE(0x676370), which is |
52 | not found anywhere I looked :( |
53 | not found anywhere I looked :( |
… | |
… | |
61 | in the global &Test::testsub. |
62 | in the global &Test::testsub. |
62 | referenced by REF(0x77bc80), which is |
63 | referenced by REF(0x77bc80), which is |
63 | in the global $Test::hash2. |
64 | in the global $Test::hash2. |
64 | |
65 | |
65 | |
66 | |
66 | It is a bit convoluted to read, but basically it says that the value stored in C<$var> |
67 | It is a bit convoluted to read, but basically it says that the value |
67 | can be found: |
68 | stored in C<$var> can be found: |
68 | |
69 | |
69 | =over 4 |
70 | =over 4 |
70 | |
71 | |
71 | =item - in some variable C<$x> whose origin is not known (I frankly have no |
72 | =item - in some variable C<$x> whose origin is not known (I frankly have no |
72 | idea why, hints accepted). |
73 | idea why, hints accepted). |
… | |
… | |
166 | |
167 | |
167 | =head1 BUGS |
168 | =head1 BUGS |
168 | |
169 | |
169 | Only code values, arrays, hashes, scalars and magic are being looked at. |
170 | Only code values, arrays, hashes, scalars and magic are being looked at. |
170 | |
171 | |
|
|
172 | This is a quick hack only. |
|
|
173 | |
171 | =head1 COPYRIGHT AND LICENSE |
174 | =head1 COPYRIGHT AND LICENSE |
172 | |
175 | |
173 | Copyright (C) 2007 by Marc Lehmann. |
176 | Copyright (C) 2007 by Marc Lehmann. |
174 | |
177 | |
175 | This library is free software; you can redistribute it and/or modify |
178 | This library is free software; you can redistribute it and/or modify |