line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package List::AssignRef; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
68462
|
use 5.006; |
|
1
|
|
|
|
|
4
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
6
|
1
|
|
|
1
|
|
464
|
use LV qw( lvalue ); |
|
1
|
|
|
|
|
3860
|
|
|
1
|
|
|
|
|
57
|
|
7
|
1
|
|
|
1
|
|
7
|
use Carp qw( confess ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
8
|
1
|
|
|
1
|
|
6
|
use Scalar::Util qw( reftype ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
48
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use constant { |
11
|
1
|
|
|
|
|
68
|
SCALAR => 'SCALAR', |
12
|
|
|
|
|
|
|
ARRAY => 'ARRAY', |
13
|
|
|
|
|
|
|
HASH => 'HASH', |
14
|
1
|
|
|
1
|
|
5
|
}; |
|
1
|
|
|
|
|
2
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use constant { |
17
|
1
|
|
|
|
|
63
|
ERR_UNSUPPORTED => "Unsupported reference type: %s", |
18
|
|
|
|
|
|
|
ERR_MISMATCH => "Reference type mismatch: %s vs %s", |
19
|
1
|
|
|
1
|
|
6
|
}; |
|
1
|
|
|
|
|
2
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
BEGIN { |
22
|
1
|
|
|
1
|
|
3
|
$List::AssignRef::AUTHORITY = 'cpan:TOBYINK'; |
23
|
1
|
|
|
|
|
29
|
$List::AssignRef::VERSION = '0.005'; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
1
|
|
426
|
use Exporter::Shiny our @EXPORT = qw( deref ); |
|
1
|
|
|
|
|
4058
|
|
|
1
|
|
|
|
|
9
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _confessf |
29
|
|
|
|
|
|
|
{ |
30
|
1
|
|
|
1
|
|
3
|
my $fmt = shift; |
31
|
1
|
|
|
|
|
252
|
confess sprintf $fmt, @_; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub deref (\[$@%]) :lvalue |
35
|
|
|
|
|
|
|
{ |
36
|
6
|
|
|
6
|
1
|
2570
|
my $given = shift; |
37
|
|
|
|
|
|
|
lvalue get => sub { |
38
|
0
|
0
|
|
0
|
|
0
|
reftype($given) eq SCALAR ? $$given : |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
39
|
|
|
|
|
|
|
reftype($given) eq ARRAY ? @$given : |
40
|
|
|
|
|
|
|
reftype($given) eq HASH ? %$given : |
41
|
|
|
|
|
|
|
_confessf(ERR_UNSUPPORTED, reftype($given)); |
42
|
|
|
|
|
|
|
}, |
43
|
|
|
|
|
|
|
set => sub { |
44
|
6
|
|
|
6
|
|
71
|
my $assign = shift; |
45
|
6
|
100
|
|
|
|
35
|
reftype($given) eq reftype($assign) |
46
|
|
|
|
|
|
|
or _confessf(ERR_MISMATCH, reftype($given), reftype($assign)); |
47
|
5
|
50
|
|
|
|
34
|
reftype($given) eq SCALAR ? ($$given = $$assign): |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
48
|
|
|
|
|
|
|
reftype($given) eq ARRAY ? (@$given = @$assign): |
49
|
|
|
|
|
|
|
reftype($given) eq HASH ? (%$given = %$assign): |
50
|
|
|
|
|
|
|
_confessf(ERR_UNSUPPORTED, reftype($given)); |
51
|
|
|
|
|
|
|
} |
52
|
6
|
|
|
|
|
40
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |