line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Embed::Util; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Data::Embed::Util::VERSION = '0.21'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: embed arbitrary data in a file - utilities |
7
|
|
|
|
|
|
|
|
8
|
8
|
|
|
8
|
|
41
|
use strict; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
386
|
|
9
|
8
|
|
|
8
|
|
40
|
use warnings; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
284
|
|
10
|
8
|
|
|
8
|
|
37
|
use English qw< -no_match_vars >; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
54
|
|
11
|
|
|
|
|
|
|
|
12
|
8
|
|
|
8
|
|
3190
|
use Exporter qw< import >; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
804
|
|
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw< STARTER TERMINATOR escape unescape >; |
14
|
|
|
|
|
|
|
our @EXPORT = (); # export nothing by default |
15
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
16
|
|
|
|
|
|
|
all => \@EXPORT_OK, |
17
|
|
|
|
|
|
|
escaping => [qw< escape unescape >], |
18
|
|
|
|
|
|
|
constants => [qw< STARTER TERMINATOR >], |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
8
|
|
|
8
|
|
45
|
use constant STARTER => "Data::Embed/index/begin\n"; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
672
|
|
23
|
8
|
|
|
8
|
|
42
|
use constant TERMINATOR => "Data::Embed/index/end\n"; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
1811
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub escape { |
26
|
108
|
|
|
108
|
1
|
253
|
my $text = shift; |
27
|
108
|
|
|
|
|
588
|
$text =~ s{([^\w.-])}{'%' . sprintf('%02x', ord $1)}egmxs, |
|
162
|
|
|
|
|
1255
|
|
28
|
|
|
|
|
|
|
return $text; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub unescape { |
32
|
3
|
|
|
3
|
1
|
4
|
my $text = shift; |
33
|
3
|
|
|
|
|
8
|
$text =~ s{%(..)}{chr(hex($1))}egmxs; |
|
4
|
|
|
|
|
13
|
|
34
|
3
|
|
|
|
|
7
|
return $text; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |