| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Hash::Args; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
66807
|
use strict; |
|
|
2
|
|
|
|
|
13
|
|
|
|
2
|
|
|
|
|
94
|
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
71
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
2043
|
use parent qw( Exporter ); |
|
|
2
|
|
|
|
|
757
|
|
|
|
2
|
|
|
|
|
10
|
|
|
7
|
2
|
|
|
2
|
|
97
|
use Carp (); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
29
|
|
|
8
|
2
|
|
|
2
|
|
10
|
use Scalar::Util (); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
526
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
|
11
|
|
|
|
|
|
|
our @EXPORT = qw( hash ); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub hash { |
|
15
|
8
|
|
|
8
|
1
|
3829
|
my $hash; |
|
16
|
|
|
|
|
|
|
|
|
17
|
8
|
100
|
100
|
|
|
43
|
if( @_ == 1 && ref $_[0] ne '' ) { |
|
18
|
5
|
|
|
|
|
7
|
my $arg = shift; |
|
19
|
5
|
|
|
|
|
6
|
my $ref = ref $arg; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# objects and HASH refs are just pass-throughs |
|
22
|
5
|
100
|
100
|
|
|
34
|
if( Scalar::Util::blessed( $arg ) || $ref eq 'HASH' ) { |
|
|
|
100
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
4
|
$hash = $arg; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# ARRAY refs must be key/value pairs |
|
27
|
|
|
|
|
|
|
elsif( $ref eq 'ARRAY' ) { |
|
28
|
2
|
100
|
|
|
|
109
|
Carp::confess( 'Unable to coerce to HASH reference from ARRAY reference with odd number of elements' ) |
|
29
|
|
|
|
|
|
|
if @$arg % 2 == 1; |
|
30
|
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
4
|
$hash = +{ @$arg }; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# i don't even... |
|
35
|
|
|
|
|
|
|
else { |
|
36
|
1
|
|
|
|
|
129
|
Carp::confess( 'Unable to coerce to HASH reference from unknown reference type ('. $ref. ')' ) |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
else { |
|
40
|
3
|
100
|
|
|
|
255
|
Carp::confess( 'Unable to coerce to HASH reference from LIST with odd number of elements' ) |
|
41
|
|
|
|
|
|
|
if @_ % 2 == 1; |
|
42
|
|
|
|
|
|
|
|
|
43
|
2
|
|
|
|
|
5
|
$hash = +{ @_ }; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
5
|
|
|
|
|
11
|
$hash |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1 |
|
51
|
|
|
|
|
|
|
__END__ |