| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Devel::WatchVars::Tie::Scalar; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf8 |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=cut |
|
6
|
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
63
|
use utf8; |
|
|
8
|
|
|
|
|
19
|
|
|
|
8
|
|
|
|
|
58
|
|
|
8
|
8
|
|
|
8
|
|
274
|
use strict; |
|
|
8
|
|
|
|
|
16
|
|
|
|
8
|
|
|
|
|
165
|
|
|
9
|
8
|
|
|
8
|
|
41
|
use warnings; |
|
|
8
|
|
|
|
|
19
|
|
|
|
8
|
|
|
|
|
200
|
|
|
10
|
8
|
|
|
8
|
|
43
|
no overloading; |
|
|
8
|
|
|
|
|
17
|
|
|
|
8
|
|
|
|
|
309
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
8
|
|
|
8
|
|
50
|
use Carp qw(shortmess); |
|
|
8
|
|
|
|
|
15
|
|
|
|
8
|
|
|
|
|
1190
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = "v1.0.5"; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
(my $PKG = __PACKAGE__) =~ s/::Tie::Scalar//; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
push our @CARP_NOT => $PKG, qw( |
|
19
|
|
|
|
|
|
|
Data::Dump |
|
20
|
|
|
|
|
|
|
Data::Dumper |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
|
|
23
|
8
|
|
|
8
|
|
3924
|
use Devel::GlobalDestruction; |
|
|
8
|
|
|
|
|
4157
|
|
|
|
8
|
|
|
|
|
47
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub mycarp { |
|
26
|
|
|
|
|
|
|
local $\; |
|
27
|
|
|
|
|
|
|
print STDERR &mymess; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub mymess { |
|
31
|
|
|
|
|
|
|
local $Carp::Verbose = $ENV{DEVEL_WATCHVARS_VERBOSE} ? 1 : 0; |
|
32
|
|
|
|
|
|
|
return &shortmess; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub redef($) { |
|
36
|
|
|
|
|
|
|
return $_[0] // "undef"; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
8
|
|
|
8
|
|
1385
|
use namespace::clean; |
|
|
8
|
|
|
|
|
21
|
|
|
|
8
|
|
|
|
|
59
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
########################################################### |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub TIESCALAR { |
|
44
|
3
|
|
|
3
|
|
12
|
my($class, $name, $value) = @_; |
|
45
|
3
|
100
|
|
|
|
11
|
unless ($name) { |
|
46
|
1
|
|
|
|
|
6
|
$name = mymess "some scalar variable"; |
|
47
|
1
|
|
|
|
|
708
|
$name =~ s/ at (\S.*) (line \d+)[.]?\n\z/ watched at $2 of $1/; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
3
|
|
|
|
|
20
|
mycarp "WATCH $name = ", redef $value; |
|
50
|
3
|
|
|
|
|
2393
|
return bless { |
|
51
|
|
|
|
|
|
|
name => $name, |
|
52
|
|
|
|
|
|
|
value => $value, |
|
53
|
|
|
|
|
|
|
}, $class; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub FETCH { |
|
57
|
10
|
|
|
10
|
|
1825
|
my($self) = @_; |
|
58
|
10
|
|
|
|
|
50
|
mycarp "FETCH $$self{name} --> ", redef $$self{value}; |
|
59
|
10
|
|
|
|
|
6111
|
return $$self{value}; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub STORE { |
|
63
|
5
|
|
|
5
|
|
23
|
my($self, $new_value) = @_; |
|
64
|
5
|
|
|
|
|
25
|
mycarp "STORE $$self{name} <-- ", redef $new_value; |
|
65
|
5
|
|
|
|
|
2951
|
return $$self{value} = $new_value; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub DESTROY { |
|
69
|
3
|
|
|
3
|
|
22
|
my($self) = @_; |
|
70
|
3
|
100
|
50
|
|
|
113
|
my $action = |
|
|
|
50
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
in_global_destruction ? "DESTROY (during global destruction)" |
|
72
|
|
|
|
|
|
|
: ((caller 2)[3] // "") eq "${PKG}::unwatch" ? "UNWATCH" |
|
73
|
|
|
|
|
|
|
: "DESTROY"; |
|
74
|
3
|
|
|
|
|
98
|
mycarp "$action $$self{name} = ", redef $$self{value}; |
|
75
|
3
|
100
|
|
|
|
2126
|
if (my $sref = $$self{sref}) { |
|
76
|
2
|
50
|
|
|
|
62
|
$$sref = $$self{value} unless in_global_destruction; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
3
|
|
|
|
|
46
|
delete @$self{keys %$self}; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |