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.28 by root, Sat Apr 13 06:29:39 2013 UTC vs.
Revision 1.29 by root, Sat Apr 13 06:53:33 2013 UTC

30The C<track> function can help track down some of those references back to 30The C<track> function can help track down some of those references back to
31the variables containing them. 31the variables containing them.
32 32
33For example, for this fragment: 33For example, for this fragment:
34 34
35 package Test; 35 package Test;
36 36
37 use Devel::FindRef; 37 use Devel::FindRef;
38 use Scalar::Util; 38 use Scalar::Util;
39 39
40 our $var = "hi\n"; 40 our $var = "hi\n";
41 my $global_my = \$var; 41 my $global_my = \$var;
42 our %global_hash = (ukukey => \$var); 42 our %global_hash = (ukukey => \$var);
43 our $global_hashref = { ukukey2 => \$var }; 43 our $global_hashref = { ukukey2 => \$var };
44 44
45 sub testsub { 45 sub testsub {
46 my $testsub_local = $global_hashref; 46 my $testsub_local = $global_hashref;
47 print Devel::FindRef::track \$var; 47 print Devel::FindRef::track \$var;
48 } 48 }
49
50 49
51 my $closure = sub { 50 my $closure = sub {
52 my $closure_var = \$_[0]; 51 my $closure_var = \$_[0];
53 Scalar::Util::weaken (my $weak_ref = \$var); 52 Scalar::Util::weaken (my $weak_ref = \$var);
54 testsub; 53 testsub;
109 108
110=back 109=back
111 110
112And all these account for six reference counts. 111And all these account for six reference counts.
113 112
114
115=head1 EXPORTS 113=head1 EXPORTS
116 114
117None. 115None.
118 116
119=head1 FUNCTIONS 117=head1 FUNCTIONS
124 122
125Track the perl value pointed to by C<$ref> up to a depth of C<$depth> and 123Track the perl value pointed to by C<$ref> up to a depth of C<$depth> and
126return a descriptive string. C<$ref> can point at any perl value, be it 124return a descriptive string. C<$ref> can point at any perl value, be it
127anonymous sub, hash, array, scalar etc. 125anonymous sub, hash, array, scalar etc.
128 126
129This is the function you most often use. 127This is the function you most likely want to use when tracking down
128references.
130 129
131=cut 130=cut
132 131
133sub find($); 132sub find($);
134 133
220 219
221=head1 ENVIRONMENT VARIABLES 220=head1 ENVIRONMENT VARIABLES
222 221
223You can set the environment variable C<PERL_DEVEL_FINDREF_DEPTH> to an 222You can set the environment variable C<PERL_DEVEL_FINDREF_DEPTH> to an
224integer to override the default depth in C<track>. If a call explicitly 223integer to override the default depth in C<track>. If a call explicitly
225specified a depth it is not overridden. 224specifies a depth, it is not overridden.
226 225
227=head1 AUTHOR 226=head1 AUTHOR
228 227
229Marc Lehmann <pcg@goof.com>. 228Marc Lehmann <pcg@goof.com>.
230 229
231=head1 COPYRIGHT AND LICENSE 230=head1 COPYRIGHT AND LICENSE
232 231
233Copyright (C) 2007, 2008 by Marc Lehmann. 232Copyright (C) 2007, 2008, 2009, 2013 by Marc Lehmann.
234 233
235This library is free software; you can redistribute it and/or modify 234This library is free software; you can redistribute it and/or modify
236it under the same terms as Perl itself, either Perl version 5.8.8 or, 235it under the same terms as Perl itself, either Perl version 5.8.8 or,
237at your option, any later version of Perl 5 you may have available. 236at your option, any later version of Perl 5 you may have available.
238 237

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines