in reply to script optmization

I don't understand the purpose of what you're doing, but you can move some of the work outside the main loop like this:
my @pat; foreach my $r (@seq) { my $t = $r; $t =~ s/\h+/bbb/g; push @pat, [ $r, $t ]; } while (<$fh>) { foreach my $p (@pat) { s/$p->[0]/$p->[1]/g; } print Newfile; }
And if you want to get fancy, maybe even this:
my $seq = join '|', @seq; my %seq; foreach my $r (@seq) { (my $t = $r) =~ s/\h+/bbb/g; $seq{$r} = $t; } while (<$fh>) { s/($seq)/$seq{$1}/go; print Newfile; }

Replies are listed 'Best First'.
Re^2: script optmization
by shoura (Novice) on May 14, 2017 at 14:41 UTC
    sorry but this don't work
      What does "don't work" mean? If you want help, you're going to have to give us more information.