/[webpac2]/trunk/lib/WebPAC/Output/Sorted.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Output/Sorted.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 920 by dpavlin, Tue Oct 30 22:46:51 2007 UTC revision 949 by dpavlin, Thu Nov 1 00:16:48 2007 UTC
# Line 14  __PACKAGE__->mk_accessors(qw( Line 14  __PACKAGE__->mk_accessors(qw(
14  use Sort::External;  use Sort::External;
15  use File::Path;  use File::Path;
16  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
17    use WebPAC::Common qw/force_array/;
18    
19  =head1 NAME  =head1 NAME
20    
# Line 60  sub init { Line 61  sub init {
61                  $log->info("created ", $self->path);                  $log->info("created ", $self->path);
62          }          }
63    
64            return 1;
65  }  }
66    
67    
# Line 80  sub add { Line 82  sub add {
82          $log->logdie("need id") unless defined $id;          $log->logdie("need id") unless defined $id;
83          $log->logdie("need ds") unless $ds;          $log->logdie("need ds") unless $ds;
84    
85          $log->debug("id: $id ds = ",dump($ds));          $log->debug("id: $id ds = ",sub { dump($ds) });
86    
87          my $hash = $self->ds_to_hash( $ds, 'sorted' ) || return;          my $hash = $self->ds_to_hash( $ds, 'sorted' ) || return;
88    
89          warn "add( $id, ",dump($ds)," ) => ", dump( $hash );          $log->debug("add( $id, ", sub { dump($ds) }," ) => ", sub { dump( $hash ) });
90    
91          foreach my $f ( keys %$hash ) {          foreach my $f ( keys %$hash ) {
92    
# Line 110  sub add { Line 112  sub add {
112    
113                  my @v;                  my @v;
114    
                 if ( ref( $hash->{$f} ) eq 'ARRAY' ) {  
                         @v = @{ $hash->{$f} };  
                 } else {  
                         @v =    $hash->{$f}  ;  
                 }  
   
115                  # we want LF in output file :-)                  # we want LF in output file :-)
116                  @v = map { "$_\n" } @v;                  @v = map { "$_\n" } force_array( $hash->{$f} );
117    
118                  $self->{sortex}->{$f}->feed( @v );                  $self->{sortex}->{$f}->feed( @v );
119    
# Line 155  sub finish { Line 151  sub finish {
151          }          }
152    
153          $log->info("over with sorted lists");          $log->info("over with sorted lists");
154    
155            return 1;
156  }  }
157    
158    

Legend:
Removed from v.920  
changed lines
  Added in v.949

  ViewVC Help
Powered by ViewVC 1.1.26