--- trunk/lib/WebPAC/Input.pm 2008/08/02 23:46:41 1100 +++ trunk/lib/WebPAC/Input.pm 2009/07/10 13:54:55 1236 @@ -3,12 +3,13 @@ use warnings; use strict; -use blib; +use lib 'lib'; use WebPAC::Common; use base qw/WebPAC::Common/; use Data::Dump qw/dump/; use Encode qw/decode from_to/; +use YAML; =head1 NAME @@ -242,6 +243,9 @@ %{ $arg }, ); + # save for dump and input_module + $self->{ll_db} = $ll_db; + unless (defined($ll_db)) { $log->logwarn("can't open database $arg->{path}, skipping..."); return; @@ -296,8 +300,7 @@ $log->debug("-=> $f_nr ## $l"); # codepage conversion and recode_regex -# $l = decode($input_encoding, $l, 1); - from_to( $l, $input_encoding, 'utf-8', 1 ); + $l = decode($input_encoding, $l, 1); $l =~ s/($recode_regex)/$recode_map->{$1}/g if ($recode_regex && $recode_map); # apply regexps @@ -316,7 +319,7 @@ warn "*** $d\n" if ($debug); } - $log->error("error applying regex: $r") if ($@); + $log->error("error applying regex: ",dump($r), $@) if $@; } } @@ -386,12 +389,11 @@ $self->{max_pos} = $to_rec; $log->debug("max_pos: $to_rec"); - # save for dump - $self->{ll_db} = $ll_db; - return $size; } +sub input_module { $_[0]->{ll_db} } + =head2 fetch Fetch next record from database. It will also displays progress bar. @@ -562,6 +564,10 @@ $log->debug( sub { dump($s) } ); + my $path = 'var/stats.yml'; + YAML::DumpFile( $path, $s ); + $log->info( 'created ', $path, ' with ', -s $path, ' bytes' ); + return $out; } @@ -720,6 +726,8 @@ line => $., }; $log->debug("regex: $regex"); + } else { + die "can't parse: $_"; } }