Here's a snippet of code that implements what you describe:
sub fuzzy {
my $string = shift;
my @alt;
for(my $i = 0; $i < length($string); $i++) {
my $alt = $string;
substr($alt, $i, 1) = 'N';
push @alt, $alt;
}
return join '|', $string, @alt; # original too
}
print fuzzy('GCGAT');
You can just do
$re = fuzzy($string);
if($value =~ /^($re)/) { ... }
Note the parens for grouping.
If there's only one value for $re during the run of the file, you can use /o (as in /^($re)/o) but in a modern perl I don't think that makes much difference.