line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
17354
|
use v5.10; |
|
1
|
|
|
|
|
3
|
|
2
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
17
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
48
|
|
4
|
|
|
|
|
|
|
package Tie::Scalar::Callback; |
5
|
|
|
|
|
|
|
$Tie::Scalar::Callback::VERSION = '0.07'; |
6
|
1
|
|
|
1
|
|
425
|
use parent 'Tie::Scalar'; |
|
1
|
|
|
|
|
250
|
|
|
1
|
|
|
|
|
6
|
|
7
|
1
|
|
|
1
|
|
1050
|
use Carp qw(carp); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
102
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#ABSTRACT: a tied scalar which executes a callback everytime it is used |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub TIESCALAR { |
12
|
4
|
|
|
4
|
|
82
|
my ($class, $sub ) = @_; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
die 'Must provide subroutine reference argument' |
15
|
4
|
100
|
100
|
0
|
|
42
|
unless $sub && ref $sub eq ref sub {}; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
|
|
13
|
bless $sub, $class; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub STORE { |
21
|
0
|
|
|
0
|
|
0
|
carp "You can't assign to this tied scalar"; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub FETCH { |
25
|
4
|
|
|
4
|
|
40
|
my ($self) = @_; |
26
|
4
|
|
|
|
|
8
|
return $self->(); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
__END__ |