line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package URI::Query::FromHash 0.005; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
31387
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
49
|
|
4
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
0
|
|
|
2
|
|
|
|
|
117
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
my %escapes; |
7
|
|
|
|
|
|
|
$escapes{+chr} = sprintf '%%%02X', $_ for 0..255; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub import { |
10
|
2
|
|
|
2
|
|
8
|
no strict 'refs'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
654
|
|
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
4
|
|
848
|
*{ caller . '::hash2query' } = \&hash2query; |
|
4
|
|
|
|
|
1314
|
|
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub hash2query(+%) { |
16
|
12
|
100
|
|
12
|
1
|
50
|
return '' if 'HASH' ne ref( my $hash = $_[0] ); |
17
|
|
|
|
|
|
|
|
18
|
10
|
|
|
|
|
13
|
my $q = ''; |
19
|
|
|
|
|
|
|
|
20
|
10
|
|
|
|
|
38
|
for my $k ( sort keys %$hash ) { |
21
|
11
|
|
|
|
|
9
|
my $v = $hash->{$k}; |
22
|
|
|
|
|
|
|
|
23
|
11
|
|
|
|
|
17
|
$k =~ s|([;/?:@&=+,\$\[\]%])|$escapes{$1}|g; |
24
|
11
|
|
|
|
|
18
|
$k =~ y| |+|; |
25
|
|
|
|
|
|
|
|
26
|
11
|
100
|
|
|
|
34
|
for ( ref $v ? @$v : $v ) { |
27
|
|
|
|
|
|
|
# Avoid modifying the original. |
28
|
15
|
|
100
|
|
|
29
|
my $v = $_ // ''; |
29
|
|
|
|
|
|
|
|
30
|
15
|
|
|
|
|
16
|
$v =~ s|([;/?:@&=+,\$\[\]%])|$escapes{$1}|g; |
31
|
15
|
|
|
|
|
10
|
$v =~ y| |+|; |
32
|
|
|
|
|
|
|
|
33
|
15
|
|
|
|
|
29
|
$q .= "$k=$v&"; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Trim off the last "&". |
38
|
10
|
|
|
|
|
18
|
substr $q, -1, 1, ''; |
39
|
|
|
|
|
|
|
|
40
|
10
|
|
|
|
|
16
|
utf8::encode $q; |
41
|
|
|
|
|
|
|
|
42
|
10
|
|
|
|
|
12
|
$q =~ s|([^\Q;/?:@&=+,\$\[\]%-_.!~*'()\EA-Za-z0-9])|@escapes{ split //, $1 }|eg; |
|
0
|
|
|
|
|
0
|
|
43
|
|
|
|
|
|
|
|
44
|
10
|
|
|
|
|
40
|
$q; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub unimport { |
48
|
2
|
|
|
2
|
|
10
|
no strict 'refs'; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
103
|
|
49
|
|
|
|
|
|
|
|
50
|
4
|
|
|
4
|
|
4074
|
delete ${ caller . '::' }{hash2query}; |
|
4
|
|
|
|
|
164
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |