--- trunk/run.pl 2007/10/30 23:32:58 921 +++ trunk/run.pl 2007/10/31 13:31:12 941 @@ -299,23 +299,11 @@ debug => $debug, }); - sub iterate_over { - my ( $what, $error ) = @_; - my @result; - if ( ref( $what ) eq 'ARRAY' ) { - @result = @{ $what }; - } elsif ($db_config->{input}) { - @result = ( $what ); - } else { - $error->() if ref($error) eq 'CODE'; - } - return @result; - } # # prepare output # - my @outputs = iterate_over( $db_config->{output}, sub { + my @outputs = force_array( $db_config->{output}, sub { $log->error("Database $database doesn't have any outputs defined. Do you want to remove it from configuration?" ); } ); @@ -330,7 +318,8 @@ $log->debug("loading output module $module"); eval "require $module"; - + + # add database to arugemnts for output filter $output->{database} = $database; $log->debug("calling $module->new(",dump( $output ),")"); @@ -346,7 +335,7 @@ # - my @inputs = iterate_over( $db_config->{input}, sub { + my @inputs = force_array( $db_config->{input}, sub { $log->info("database $database doesn't have inputs defined"); } ); @@ -520,6 +509,16 @@ } + # setup input name for all output filters + foreach my $out ( @output_modules ) { + if ( $out->can('input') ) { + $out->input( $input_name ); + } else { + $log->warn("output filter ",ref($out)," doesn't support input name"); + } + } + + foreach my $pos ( 0 ... $input_db->size ) { my $row = $input_db->fetch || next;