line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Web::Machine::Util; |
2
|
|
|
|
|
|
|
# ABSTRACT: General Utility module |
3
|
|
|
|
|
|
|
|
4
|
19
|
|
|
19
|
|
119970
|
use strict; |
|
19
|
|
|
|
|
23
|
|
|
19
|
|
|
|
|
659
|
|
5
|
19
|
|
|
19
|
|
71
|
use warnings; |
|
19
|
|
|
|
|
24
|
|
|
19
|
|
|
|
|
696
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.16'; |
8
|
|
|
|
|
|
|
|
9
|
19
|
|
|
19
|
|
70
|
use Carp qw[ confess ]; |
|
19
|
|
|
|
|
23
|
|
|
19
|
|
|
|
|
852
|
|
10
|
19
|
|
|
19
|
|
75
|
use Scalar::Util qw[ blessed ]; |
|
19
|
|
|
|
|
27
|
|
|
19
|
|
|
|
|
955
|
|
11
|
19
|
|
|
19
|
|
88
|
use List::Util qw[ first ]; |
|
19
|
|
|
|
|
26
|
|
|
19
|
|
|
|
|
1632
|
|
12
|
|
|
|
|
|
|
|
13
|
19
|
|
|
19
|
|
9806
|
use HTTP::Headers::ActionPack 0.07; |
|
19
|
|
|
|
|
33828
|
|
|
19
|
|
|
|
|
786
|
|
14
|
|
|
|
|
|
|
|
15
|
19
|
|
|
|
|
177
|
use Sub::Exporter -setup => { |
16
|
|
|
|
|
|
|
exports => [qw[ |
17
|
|
|
|
|
|
|
first |
18
|
|
|
|
|
|
|
pair_key |
19
|
|
|
|
|
|
|
pair_value |
20
|
|
|
|
|
|
|
bind_path |
21
|
|
|
|
|
|
|
create_date |
22
|
|
|
|
|
|
|
create_header |
23
|
|
|
|
|
|
|
inflate_headers |
24
|
|
|
|
|
|
|
]] |
25
|
19
|
|
|
19
|
|
9766
|
}; |
|
19
|
|
|
|
|
147113
|
|
26
|
|
|
|
|
|
|
|
27
|
210
|
|
|
210
|
1
|
658
|
sub pair_key { ( keys %{ $_[0] } )[0] } |
|
210
|
|
|
|
|
774
|
|
28
|
54
|
|
|
54
|
1
|
64
|
sub pair_value { ( values %{ $_[0] } )[0] } |
|
54
|
|
|
|
|
146
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
{ |
31
|
|
|
|
|
|
|
my $ACTION_PACK = HTTP::Headers::ActionPack->new; |
32
|
132
|
|
|
132
|
1
|
385
|
sub create_header { $ACTION_PACK->create( @_ ) } |
33
|
21
|
|
|
21
|
1
|
1028
|
sub create_date { $ACTION_PACK->create( 'DateHeader' => shift ) } |
34
|
124
|
|
|
124
|
1
|
139549
|
sub inflate_headers { $ACTION_PACK->inflate( @_ ) } |
35
|
18
|
|
|
18
|
0
|
49
|
sub get_action_pack { $ACTION_PACK } |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub bind_path { |
39
|
22
|
|
|
22
|
1
|
42
|
my ($spec, $path) = @_; |
40
|
22
|
|
|
|
|
55
|
my @parts = grep { $_ } split /\// => $path; |
|
62
|
|
|
|
|
83
|
|
41
|
22
|
|
|
|
|
37
|
my @spec = grep { $_ } split /\// => $spec; |
|
67
|
|
|
|
|
76
|
|
42
|
|
|
|
|
|
|
|
43
|
22
|
|
|
|
|
23
|
my @results; |
44
|
22
|
|
|
|
|
43
|
foreach my $i ( 0 .. $#spec ) { |
45
|
43
|
100
|
|
|
|
139
|
if ( $spec[ $i ] =~ /^\*$/ ) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
46
|
5
|
|
|
|
|
7
|
push @results => @parts; |
47
|
5
|
|
|
|
|
6
|
@parts = (); |
48
|
5
|
|
|
|
|
6
|
last; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
elsif ( $spec[ $i ] =~ /^\:/ ) { |
51
|
15
|
100
|
|
|
|
30
|
return unless defined $parts[ 0 ]; |
52
|
14
|
|
|
|
|
21
|
push @results => shift @parts; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
elsif ( $spec[ $i ] =~ /^\?\:/ ) { |
55
|
9
|
100
|
|
|
|
26
|
push @results => shift @parts |
56
|
|
|
|
|
|
|
if defined $parts[ 0 ]; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
else { |
59
|
14
|
50
|
|
|
|
27
|
return unless defined $parts[ 0 ]; |
60
|
14
|
100
|
|
|
|
29
|
return unless $spec[ $i ] eq $parts[ 0 ]; |
61
|
13
|
|
|
|
|
17
|
shift @parts; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
20
|
100
|
|
|
|
49
|
return if @parts; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
wantarray |
68
|
|
|
|
|
|
|
? @results |
69
|
16
|
100
|
|
|
|
79
|
: (scalar @results == 1) |
|
|
100
|
|
|
|
|
|
70
|
|
|
|
|
|
|
? $results[0] |
71
|
|
|
|
|
|
|
: @results; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |