Perl Strip Comments with Regex Unique Request
- by YoDar
Hello,
I'm running a code that read files, do some parsing but need to ignore all comments.
There are good explanations how to conduct it. like this link
$/ = undef;
$_ = <>;
s#/\*[^*]*\*+([^/*][^*]*\*+)*/|("(\\.|[^"\\])*"|'(\\.|[^'\\])*'|.[^/"'\\]*)#defined $2 ? $2 : ""#gse;
print;
My first problem is that after run this line $/ = undef; my code doesn't work properly.
Actually, I don't know what it does. But if I could turn it back after ignoring all comments it will be helpful.
In general, What is the useful way to ignore all comments without changing the rest of the code ?
Thanks,
YoDar