| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package PYX::Utils; |
|
2
|
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
79097
|
use base qw(Exporter); |
|
|
6
|
|
|
|
|
45
|
|
|
|
6
|
|
|
|
|
841
|
|
|
4
|
6
|
|
|
6
|
|
41
|
use strict; |
|
|
6
|
|
|
|
|
14
|
|
|
|
6
|
|
|
|
|
133
|
|
|
5
|
6
|
|
|
6
|
|
39
|
use warnings; |
|
|
6
|
|
|
|
|
33
|
|
|
|
6
|
|
|
|
|
265
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
3337
|
use HTML::Entities qw(decode_entities); |
|
|
6
|
|
|
|
|
45558
|
|
|
|
6
|
|
|
|
|
475
|
|
|
8
|
6
|
|
|
6
|
|
3580
|
use Readonly; |
|
|
6
|
|
|
|
|
23679
|
|
|
|
6
|
|
|
|
|
1635
|
|
|
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.07; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Decode chars. |
|
22
|
|
|
|
|
|
|
sub decode { |
|
23
|
1
|
|
|
1
|
1
|
92
|
my $text = shift; |
|
24
|
1
|
|
|
|
|
4
|
$text =~ s/\n/\\n/gms; |
|
25
|
1
|
|
|
|
|
5
|
return $text; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Encode chars. |
|
29
|
|
|
|
|
|
|
sub encode { |
|
30
|
1
|
|
|
1
|
1
|
90
|
my $text = shift; |
|
31
|
1
|
|
|
|
|
6
|
$text =~ s/\\n/\n/gms; |
|
32
|
1
|
|
|
|
|
4
|
return $text; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Decode entities. |
|
36
|
|
|
|
|
|
|
sub entity_decode { |
|
37
|
4
|
|
|
4
|
1
|
1958
|
my $text = shift; |
|
38
|
4
|
|
|
|
|
33
|
return decode_entities($text); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Encode some chars for HTML/XML/SGML. |
|
42
|
|
|
|
|
|
|
sub entity_encode { |
|
43
|
4
|
|
|
4
|
1
|
1978
|
my $text = shift; |
|
44
|
4
|
|
|
|
|
59
|
$text =~ s/([$ENTITIES])/$ENTITIES{$1}/gms; |
|
45
|
4
|
|
|
|
|
60
|
return $text; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |