line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Web::Machine::Util; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
19
|
|
|
19
|
|
305515
|
$Web::Machine::Util::AUTHORITY = 'cpan:STEVAN'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
# ABSTRACT: General Utility module |
6
|
|
|
|
|
|
|
$Web::Machine::Util::VERSION = '0.15'; |
7
|
19
|
|
|
19
|
|
170
|
use strict; |
|
19
|
|
|
|
|
39
|
|
|
19
|
|
|
|
|
573
|
|
8
|
19
|
|
|
19
|
|
94
|
use warnings; |
|
19
|
|
|
|
|
37
|
|
|
19
|
|
|
|
|
638
|
|
9
|
|
|
|
|
|
|
|
10
|
19
|
|
|
19
|
|
95
|
use Carp qw[ confess ]; |
|
19
|
|
|
|
|
43
|
|
|
19
|
|
|
|
|
1103
|
|
11
|
19
|
|
|
19
|
|
100
|
use Scalar::Util qw[ blessed ]; |
|
19
|
|
|
|
|
55
|
|
|
19
|
|
|
|
|
1373
|
|
12
|
19
|
|
|
19
|
|
114
|
use List::Util qw[ first ]; |
|
19
|
|
|
|
|
35
|
|
|
19
|
|
|
|
|
2471
|
|
13
|
|
|
|
|
|
|
|
14
|
19
|
|
|
19
|
|
20958
|
use HTTP::Headers::ActionPack 0.07; |
|
19
|
|
|
|
|
63782
|
|
|
19
|
|
|
|
|
828
|
|
15
|
|
|
|
|
|
|
|
16
|
19
|
|
|
|
|
287
|
use Sub::Exporter -setup => { |
17
|
|
|
|
|
|
|
exports => [qw[ |
18
|
|
|
|
|
|
|
first |
19
|
|
|
|
|
|
|
pair_key |
20
|
|
|
|
|
|
|
pair_value |
21
|
|
|
|
|
|
|
bind_path |
22
|
|
|
|
|
|
|
create_date |
23
|
|
|
|
|
|
|
create_header |
24
|
|
|
|
|
|
|
inflate_headers |
25
|
|
|
|
|
|
|
]] |
26
|
19
|
|
|
19
|
|
16785
|
}; |
|
19
|
|
|
|
|
229668
|
|
27
|
|
|
|
|
|
|
|
28
|
209
|
|
|
209
|
1
|
1056
|
sub pair_key { ( keys %{ $_[0] } )[0] } |
|
209
|
|
|
|
|
1245
|
|
29
|
54
|
|
|
54
|
1
|
102
|
sub pair_value { ( values %{ $_[0] } )[0] } |
|
54
|
|
|
|
|
226
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
{ |
32
|
|
|
|
|
|
|
my $ACTION_PACK = HTTP::Headers::ActionPack->new; |
33
|
131
|
|
|
131
|
0
|
719
|
sub create_header { $ACTION_PACK->create( @_ ) } |
34
|
21
|
|
|
21
|
1
|
1548
|
sub create_date { $ACTION_PACK->create( 'DateHeader' => shift ) } |
35
|
123
|
|
|
123
|
1
|
300605
|
sub inflate_headers { $ACTION_PACK->inflate( @_ ) } |
36
|
18
|
|
|
18
|
0
|
59
|
sub get_action_pack { $ACTION_PACK } |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub bind_path { |
40
|
22
|
|
|
22
|
1
|
61
|
my ($spec, $path) = @_; |
41
|
22
|
|
|
|
|
75
|
my @parts = grep { $_ } split /\// => $path; |
|
62
|
|
|
|
|
149
|
|
42
|
22
|
|
|
|
|
59
|
my @spec = grep { $_ } split /\// => $spec; |
|
67
|
|
|
|
|
139
|
|
43
|
|
|
|
|
|
|
|
44
|
22
|
|
|
|
|
33
|
my @results; |
45
|
22
|
|
|
|
|
60
|
foreach my $i ( 0 .. $#spec ) { |
46
|
43
|
100
|
|
|
|
203
|
if ( $spec[ $i ] =~ /^\*$/ ) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
47
|
5
|
|
|
|
|
10
|
push @results => @parts; |
48
|
5
|
|
|
|
|
8
|
@parts = (); |
49
|
5
|
|
|
|
|
9
|
last; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
elsif ( $spec[ $i ] =~ /^\:/ ) { |
52
|
15
|
100
|
|
|
|
39
|
return unless defined $parts[ 0 ]; |
53
|
14
|
|
|
|
|
37
|
push @results => shift @parts; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
elsif ( $spec[ $i ] =~ /^\?\:/ ) { |
56
|
9
|
100
|
|
|
|
36
|
push @results => shift @parts |
57
|
|
|
|
|
|
|
if defined $parts[ 0 ]; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
else { |
60
|
14
|
50
|
|
|
|
33
|
return unless defined $parts[ 0 ]; |
61
|
14
|
100
|
|
|
|
40
|
return unless $spec[ $i ] eq $parts[ 0 ]; |
62
|
13
|
|
|
|
|
42
|
shift @parts; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
20
|
100
|
|
|
|
68
|
return if @parts; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
wantarray |
69
|
|
|
|
|
|
|
? @results |
70
|
16
|
100
|
|
|
|
134
|
: (scalar @results == 1) |
|
|
100
|
|
|
|
|
|
71
|
|
|
|
|
|
|
? $results[0] |
72
|
|
|
|
|
|
|
: @results; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |