in reply to Re: Re: Replace character not inside comments
in thread Replace character not inside comments

just adding an s modifier to each regex ought to do it: it'll then treat the whole thing as if it were one line (or, strictly, it'll treat line-endings as just another character), as the early parts of perlre will explain. I should have put that in, but your example was just one line so I didn't bother:

$test =~ s/(\\\*.*?\*\\)/ push @comments, $1; '%%comment%%' /egs; $test =~ s/\\//gs; $test =~ s/%%comment%%/ shift @comments /egs;