… | |
… | |
2 | |
2 | |
3 | use strict; |
3 | use strict; |
4 | |
4 | |
5 | use XSLoader; |
5 | use XSLoader; |
6 | |
6 | |
7 | |
|
|
8 | BEGIN { |
7 | BEGIN { |
9 | our $VERSION = '0.1'; |
8 | our $VERSION = '1.0'; |
10 | XSLoader::load __PACKAGE__, $VERSION; |
9 | XSLoader::load __PACKAGE__, $VERSION; |
11 | } |
10 | } |
12 | |
11 | |
13 | =head1 NAME |
12 | =head1 NAME |
14 | |
13 | |
… | |
… | |
78 | |
77 | |
79 | =item - in the hash element C<ukukey2>, in the hash in the my variable |
78 | =item - in the hash element C<ukukey2>, in the hash in the my variable |
80 | C<$local> in the sub C<Test::testsub> and also in the hash referenced by |
79 | C<$local> in the sub C<Test::testsub> and also in the hash referenced by |
81 | C<$Test::hash2>. |
80 | C<$Test::hash2>. |
82 | |
81 | |
|
|
82 | =back |
|
|
83 | |
83 | =head1 EXPORTS |
84 | =head1 EXPORTS |
84 | |
85 | |
85 | None. |
86 | None. |
86 | |
87 | |
87 | =head1 FUNCTIONS |
88 | =head1 FUNCTIONS |
… | |
… | |
100 | |
101 | |
101 | sub find($); |
102 | sub find($); |
102 | |
103 | |
103 | sub track { |
104 | sub track { |
104 | my $buf = ""; |
105 | my $buf = ""; |
|
|
106 | my %ignore; |
105 | |
107 | |
106 | my $track; $track = sub { |
108 | my $track; $track = sub { |
107 | my (undef, $depth, $indent) = @_; |
109 | my ($target, $depth, $indent) = @_; |
|
|
110 | @_ = (); |
|
|
111 | local $ignore{$target+0} = undef; |
108 | |
112 | |
109 | if ($depth) { |
113 | if ($depth) { |
110 | my (@about) = find $_[0]; |
114 | my (@about) = grep !exists $ignore{$_->[1]}, find $target; |
111 | if (@about) { |
115 | if (@about) { |
|
|
116 | local @ignore{map $_->[1]+0, @about} = (); |
112 | for my $about (@about) { |
117 | for my $about (@about) { |
|
|
118 | local $ignore{$about+0} = undef; |
113 | $buf .= (" ") x $indent; |
119 | $buf .= (" ") x $indent; |
114 | $buf .= $about->[0]; |
120 | $buf .= $about->[0]; |
115 | if (@$about > 1) { |
121 | if (@$about > 1) { |
116 | $buf .= " $about->[1], which is\n"; |
122 | $buf .= " $about->[1], which is\n"; |
117 | $track->($about->[1], $depth - 1, $indent + 1); |
123 | $track->($about->[1], $depth - 1, $indent + 1); |
… | |
… | |
146 | |
152 | |
147 | =cut |
153 | =cut |
148 | |
154 | |
149 | sub find($) { |
155 | sub find($) { |
150 | my ($about, $excl) = &find_; |
156 | my ($about, $excl) = &find_; |
151 | my %excl = map +($_ => 1), @$excl; |
157 | my %excl = map +($_ => undef), @$excl; |
152 | grep !$excl{$_->[1] + 0}, @$about |
158 | grep !exists $excl{$_->[1] + 0}, @$about |
153 | } |
159 | } |
154 | |
160 | |
155 | =item $ref = Devel::FindRef::ref2ptr $ptr |
161 | =item $ref = Devel::FindRef::ptr2ref $integer |
156 | |
162 | |
157 | Sometimes you know (from debugging output) the address of a perl scalar |
163 | Sometimes you know (from debugging output) the address of a perl scalar |
158 | you are interested in. This function can be used to turn the address into |
164 | you are interested in (e.g. C<HASH(0x176ff70)>). This function can be used |
159 | a reference to that scalar. It is quite safe to call on valid addresses, |
165 | to turn the address into a reference to that scalar. It is quite safe to |
160 | but extremely dangerous to call on invalid ones. |
166 | call on valid addresses, but extremely dangerous to call on invalid ones. |
|
|
167 | |
|
|
168 | # we know that HASH(0x176ff70) exists, so turn it into a hashref: |
|
|
169 | my $ref_to_hash = Devel::FindRef::ptr2ref 0x176ff70; |
161 | |
170 | |
162 | =back |
171 | =back |
163 | |
172 | |
164 | =head1 AUTHOR |
173 | =head1 AUTHOR |
165 | |
174 | |