line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# vi: set ts=4 sw=4 ht=4 et : |
2
|
|
|
|
|
|
|
package perl5i::1::HASH; |
3
|
1
|
|
|
1
|
|
16
|
use 5.010; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
218
|
|
7
|
|
|
|
|
|
|
require Carp; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub flip { |
10
|
0
|
|
|
|
|
|
Carp::croak("Can't flip hash with references as values") |
11
|
0
|
0
|
|
0
|
0
|
|
if grep { ref } values %{$_[0]}; |
|
0
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
|
|
|
my %flipped = reverse %{$_[0]}; |
|
0
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
0
|
0
|
|
|
|
|
return wantarray ? %flipped : \%flipped; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub merge { |
19
|
0
|
|
|
0
|
0
|
|
require Hash::Merge::Simple; |
20
|
0
|
|
|
|
|
|
my $merged = Hash::Merge::Simple::merge(@_); |
21
|
|
|
|
|
|
|
|
22
|
0
|
0
|
|
|
|
|
return wantarray ? %$merged : $merged; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub print { |
26
|
0
|
|
|
0
|
0
|
|
my $hash = shift; |
27
|
0
|
|
|
|
|
|
print join(" ", map { "$_ => $hash->{$_}" } keys %$hash); |
|
0
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub say { |
31
|
0
|
|
|
0
|
0
|
|
my $hash = shift; |
32
|
0
|
|
|
|
|
|
print join(" ", map { "$_ => $hash->{$_}" } keys %$hash), "\n"; |
|
0
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |