7 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
10 my ( $run_time_beg, $run_time_end, $options, $in, $out, $record, @vals, $i );
12 $run_time_beg = Maasha::Biopieces::run_time();
14 Maasha::Biopieces::log_biopiece();
16 $options = Maasha::Biopieces::parse_options(
18 { long => 'key', short => 'k', type => 'string', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
19 { long => 'keys', short => 'K', type => 'list', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
20 { long => 'delimit', short => 'd', type => 'string', mandatory => 'no', default => '_', allowed => undef, disallowed => undef },
24 $in = Maasha::Biopieces::read_stream( $options->{ "stream_in" } );
25 $out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } );
27 while ( $record = Maasha::Biopieces::get_record( $in ) )
29 if ( exists $options->{ 'key' } and exists $record->{ $options->{ 'key' } } )
31 @vals = split /$options->{ 'delimit' }/, $record->{ $options->{ 'key' } };
33 for ( $i = 0; $i < @vals; $i++ )
35 if ( defined $options->{ "keys" } and defined $options->{ "keys" }->[ $i ] ) {
36 $record->{ $options->{ "keys" }->[ $i ] } = $vals[ $i ];
38 $record->{ $options->{ 'key' } . "_$i" } = $vals[ $i ];
43 Maasha::Biopieces::put_record( $record, $out );
49 $run_time_end = Maasha::Biopieces::run_time();
51 Maasha::Biopieces::run_time_print( $run_time_beg, $run_time_end, $options );
54 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<