# Solution 2: my $s_mask = unpack ("b*",$mask); my $pos=0; print "Res: "; while ($pos < length($seq)){ no warnings; ## $s_mask could be shorter than $seq print ! substr($s_mask,$pos,1) ? substr($seq,$pos,1) : "x"; $pos++; } print "\n";