in reply to Replace character not inside comments

Assuming the string to be modified is in $_:
$_ = do {my $t = ""; $t .= defined $1 ? do {(my $t = $1) =~ y/\\//d; $t} : $2 while /((?:[^\\]+|\\(?!\*))+)|(\\\*(?:[^*]+|\*(?!\\) +)+\*\\)/g; $t };
Abigail