use strict; use warnings; use MCE::Flow; use MCE::Shared; mce_open my $out_fh, '>', \*STDOUT or die "open error: $!\n"; mce_flow { max_workers => 4, chunk_size => '2m', input_data => "input_file.fasta", RS => "\n>", }, sub { my ( $mce, $chunk_ref, $chunk_id ) = @_; my ( $name, $output ); for ( @{ $chunk_ref } ) { /^>(\w+)/; $name = $1; tr/\t\r\n //d; # trim white space while ( $_ =~ /(?<=(.....))CCCC(.{10})AGA(?=(.....))/g ) { $output .= "$name: $1, $2, $3\n"; } } print $out_fh $output if length($output); };