line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PYX::Utils; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
74756
|
use base qw(Exporter); |
|
6
|
|
|
|
|
35
|
|
|
6
|
|
|
|
|
739
|
|
4
|
6
|
|
|
6
|
|
38
|
use strict; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
115
|
|
5
|
6
|
|
|
6
|
|
35
|
use warnings; |
|
6
|
|
|
|
|
26
|
|
|
6
|
|
|
|
|
209
|
|
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
2959
|
use HTML::Entities qw(decode_entities); |
|
6
|
|
|
|
|
40561
|
|
|
6
|
|
|
|
|
439
|
|
8
|
6
|
|
|
6
|
|
3042
|
use Readonly; |
|
6
|
|
|
|
|
21829
|
|
|
6
|
|
|
|
|
1506
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# Constants. |
11
|
|
|
|
|
|
|
Readonly::Array our @EXPORT_OK => qw(decode encode entity_decode entity_encode); |
12
|
|
|
|
|
|
|
Readonly::Hash our %ENTITIES => ( |
13
|
|
|
|
|
|
|
'<' => '<', |
14
|
|
|
|
|
|
|
q{&} => '&', |
15
|
|
|
|
|
|
|
q{"} => '"', |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
Readonly::Scalar our $ENTITIES => join q{}, keys %ENTITIES; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = 0.06; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Decode chars. |
22
|
|
|
|
|
|
|
sub decode { |
23
|
1
|
|
|
1
|
1
|
68
|
my $text = shift; |
24
|
1
|
|
|
|
|
4
|
$text =~ s/\n/\\n/gms; |
25
|
1
|
|
|
|
|
3
|
return $text; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Encode chars. |
29
|
|
|
|
|
|
|
sub encode { |
30
|
1
|
|
|
1
|
1
|
86
|
my $text = shift; |
31
|
1
|
|
|
|
|
5
|
$text =~ s/\\n/\n/gms; |
32
|
1
|
|
|
|
|
4
|
return $text; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Decode entities. |
36
|
|
|
|
|
|
|
sub entity_decode { |
37
|
4
|
|
|
4
|
1
|
1645
|
my $text = shift; |
38
|
4
|
|
|
|
|
27
|
return decode_entities($text); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Encode some chars for HTML/XML/SGML. |
42
|
|
|
|
|
|
|
sub entity_encode { |
43
|
4
|
|
|
4
|
1
|
1972
|
my $text = shift; |
44
|
4
|
|
|
|
|
62
|
$text =~ s/([$ENTITIES])/$ENTITIES{$1}/gms; |
45
|
4
|
|
|
|
|
60
|
return $text; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |