use strict; use warnings; my $a = 'AYGTACTAGACTACAGACTACAGACATCTACAGACTCATCAGCAGCATATTTA'; my $b = 'ACGTACTAGACTACAGACTACAGACATCTACAGACTCATCAGCAGCATATTKA'; my $merged = $a; while ($b =~ /([RYSWKMBDHV])/g) { my $pos = $-[0]; substr $merged, $pos, 1, $1; } # $merge contains what you want
The only "unusual" thing in there is the usage of @- to get the match position.
In reply to Re: merging dna sequences
by moritz
in thread merging dna sequences
by garyboyd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |