line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Embed::Util; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Data::Embed::Util::VERSION = '0.2_03'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: embed arbitrary data in a file - utilities |
7
|
|
|
|
|
|
|
|
8
|
8
|
|
|
8
|
|
39
|
use strict; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
273
|
|
9
|
8
|
|
|
8
|
|
32
|
use warnings; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
215
|
|
10
|
8
|
|
|
8
|
|
27
|
use English qw< -no_match_vars >; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
39
|
|
11
|
|
|
|
|
|
|
|
12
|
8
|
|
|
8
|
|
2651
|
use Exporter qw< import >; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
661
|
|
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
|
|
38
|
use constant STARTER => "Data::Embed/index/begin\n"; |
|
8
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
548
|
|
23
|
8
|
|
|
8
|
|
108
|
use constant TERMINATOR => "Data::Embed/index/end\n"; |
|
8
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
1513
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub escape { |
26
|
108
|
|
|
108
|
1
|
223
|
my $text = shift; |
27
|
108
|
|
|
|
|
581
|
$text =~ s{([^\w.-])}{'%' . sprintf('%02x', ord $1)}egmxs, |
|
162
|
|
|
|
|
1120
|
|
28
|
|
|
|
|
|
|
return $text; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub unescape { |
32
|
3
|
|
|
3
|
1
|
5
|
my $text = shift; |
33
|
3
|
|
|
|
|
9
|
$text =~ s{%(..)}{chr(hex($1))}egmxs; |
|
4
|
|
|
|
|
10
|
|
34
|
3
|
|
|
|
|
8
|
return $text; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |