3 |
use warnings; |
use warnings; |
4 |
use strict; |
use strict; |
5 |
|
|
6 |
use blib; |
use lib 'lib'; |
7 |
|
|
8 |
use WebPAC::Common; |
use WebPAC::Common; |
9 |
use base qw/WebPAC::Common/; |
use base qw/WebPAC::Common/; |
10 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
11 |
use Encode qw/decode from_to/; |
use Encode qw/decode from_to/; |
12 |
|
use YAML; |
13 |
|
|
14 |
=head1 NAME |
=head1 NAME |
15 |
|
|
243 |
%{ $arg }, |
%{ $arg }, |
244 |
); |
); |
245 |
|
|
246 |
|
# save for dump and input_module |
247 |
|
$self->{ll_db} = $ll_db; |
248 |
|
|
249 |
unless (defined($ll_db)) { |
unless (defined($ll_db)) { |
250 |
$log->logwarn("can't open database $arg->{path}, skipping..."); |
$log->logwarn("can't open database $arg->{path}, skipping..."); |
251 |
return; |
return; |
300 |
$log->debug("-=> $f_nr ## $l"); |
$log->debug("-=> $f_nr ## $l"); |
301 |
|
|
302 |
# codepage conversion and recode_regex |
# codepage conversion and recode_regex |
303 |
# $l = decode($input_encoding, $l, 1); |
$l = decode($input_encoding, $l, 1); |
|
from_to( $l, $input_encoding, 'utf-8', 1 ); |
|
304 |
$l =~ s/($recode_regex)/$recode_map->{$1}/g if ($recode_regex && $recode_map); |
$l =~ s/($recode_regex)/$recode_map->{$1}/g if ($recode_regex && $recode_map); |
305 |
|
|
306 |
# apply regexps |
# apply regexps |
319 |
warn "*** $d\n" if ($debug); |
warn "*** $d\n" if ($debug); |
320 |
|
|
321 |
} |
} |
322 |
$log->error("error applying regex: $r") if ($@); |
$log->error("error applying regex: ",dump($r), $@) if $@; |
323 |
} |
} |
324 |
} |
} |
325 |
|
|
389 |
$self->{max_pos} = $to_rec; |
$self->{max_pos} = $to_rec; |
390 |
$log->debug("max_pos: $to_rec"); |
$log->debug("max_pos: $to_rec"); |
391 |
|
|
|
# save for dump |
|
|
$self->{ll_db} = $ll_db; |
|
|
|
|
392 |
return $size; |
return $size; |
393 |
} |
} |
394 |
|
|
395 |
|
sub input_module { $_[0]->{ll_db} } |
396 |
|
|
397 |
=head2 fetch |
=head2 fetch |
398 |
|
|
399 |
Fetch next record from database. It will also displays progress bar. |
Fetch next record from database. It will also displays progress bar. |
564 |
|
|
565 |
$log->debug( sub { dump($s) } ); |
$log->debug( sub { dump($s) } ); |
566 |
|
|
567 |
|
my $path = 'var/stats.yml'; |
568 |
|
YAML::DumpFile( $path, $s ); |
569 |
|
$log->info( 'created ', $path, ' with ', -s $path, ' bytes' ); |
570 |
|
|
571 |
return $out; |
return $out; |
572 |
} |
} |
573 |
|
|
726 |
line => $., |
line => $., |
727 |
}; |
}; |
728 |
$log->debug("regex: $regex"); |
$log->debug("regex: $regex"); |
729 |
|
} else { |
730 |
|
die "can't parse: $_"; |
731 |
} |
} |
732 |
} |
} |
733 |
|
|