line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Lipsum::Chinese; |
2
|
4
|
|
|
4
|
|
86369
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
144
|
|
3
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
114
|
|
4
|
4
|
|
|
4
|
|
3270
|
use LWP::Simple; |
|
4
|
|
|
|
|
318220
|
|
|
4
|
|
|
|
|
35
|
|
5
|
4
|
|
|
4
|
|
1788
|
use Encode; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
1597
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
3
|
|
|
3
|
1
|
46
|
return bless {}; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub generate { |
13
|
1
|
|
|
1
|
1
|
6
|
my ($self) = @_; |
14
|
1
|
|
|
|
|
4
|
$self->_fetch; |
15
|
1
|
|
|
|
|
6
|
$self->_to_utf8; |
16
|
1
|
|
|
|
|
6
|
$self->_parse; |
17
|
1
|
|
|
|
|
6
|
return $self->{content}; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _fetch { |
21
|
2
|
|
|
2
|
|
8
|
my ($self) = @_; |
22
|
2
|
50
|
|
|
|
14
|
my $content = get("http://www.richyli.com/tool/loremipsum/") |
23
|
|
|
|
|
|
|
or die("Couldn't get lorem ipsum content from richili.com"); |
24
|
2
|
|
|
|
|
3880776
|
$self->{content} = $content; |
25
|
2
|
|
|
|
|
11
|
$self->{parsed} = 0; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _parse { |
29
|
2
|
|
|
2
|
|
24434
|
my ($self, $content) = @_; |
30
|
2
|
|
66
|
|
|
15
|
$content ||= $self->{content}; |
31
|
2
|
|
|
|
|
157
|
$content =~ s{^.*}{}s; |
32
|
2
|
|
|
|
|
39
|
$content =~ s{ .*$}{}s; |
33
|
2
|
|
|
|
|
42
|
$content =~ s{?p>}{}sg; |
34
|
2
|
|
|
|
|
12
|
$self->{parsed} = 1; |
35
|
2
|
|
|
|
|
8
|
$self->{content} = $content; |
36
|
2
|
|
|
|
|
6
|
return $content; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _to_utf8 { |
40
|
2
|
|
|
2
|
|
10
|
my $self = shift; |
41
|
2
|
50
|
|
|
|
9
|
return unless defined $self->{content}; |
42
|
2
|
50
|
|
|
|
23
|
if ( Encode::is_utf8($self->{content} )) { |
43
|
2
|
|
|
|
|
6
|
return $self->{content}; |
44
|
|
|
|
|
|
|
} |
45
|
0
|
|
|
|
|
|
$self->{content} = Encode::decode("big5", $self->{content}); |
46
|
0
|
|
|
|
|
|
return $self->{content} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |