line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: raw
|
2
|
|
|
|
|
|
|
=pod
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=encoding utf8
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 FUNCTION
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head2 parse_novel
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
解析raw 文件
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $raw_content_ref = $self->parse_novel( '/someotherdir/somefile.raw' );
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut
|
15
|
|
|
|
|
|
|
package Novel::Robot::Parser::raw;
|
16
|
1
|
|
|
1
|
|
8
|
use strict;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
17
|
1
|
|
|
1
|
|
5
|
use warnings;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
18
|
1
|
|
|
1
|
|
4
|
use base 'Novel::Robot::Parser';
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
136
|
|
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
6
|
use File::Slurp qw/read_file/;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
118
|
|
21
|
1
|
|
|
1
|
|
7
|
use Data::MessagePack;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
22
|
|
|
|
|
|
|
#use utf8;
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub parse_novel {
|
25
|
1
|
|
|
1
|
1
|
6
|
my ($self, $raw_file) = @_;
|
26
|
1
|
50
|
|
|
|
3
|
$raw_file = $raw_file->[0] if(ref($raw_file) eq 'ARRAY');
|
27
|
1
|
|
|
|
|
5
|
my $s = read_file( $raw_file, binmode => ':raw' ) ;
|
28
|
1
|
|
|
|
|
140
|
my $mp = Data::MessagePack->new();
|
29
|
1
|
|
|
|
|
7
|
$mp->utf8(0);
|
30
|
1
|
|
|
|
|
40
|
my $up = $mp->unpack($s);
|
31
|
1
|
|
|
|
|
4
|
return $up;
|
32
|
|
|
|
|
|
|
}
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1;
|