I will boil down my exact requirement to this: I should print out lines that do not contain semi-colon, backslash and closing parentheses. The following one -liner works fine.
-
perl -ne "unless(/[\\);]/) {print}" in.txt > out.txt
-
Consider the following sample data:
-
Msg_create(….); \
-
PSLogI18N\
-
Free( ….)
-
eweqwdeqwe;
-
erwerwfrrfreer)
-
rwerttrwerterter\
-
rtwert)
-
et
-
er
-
te
-
t
-
wwwwwwwwwwwwwww\\
-
erwerrwerr ;
-
But if I use the same one-liner inside a system() command in a script, backslash(\) will not be matched by the regex. Lines containing backslash will be printed out to out.txt.
-
system("perl -ne \"unless(/[\\);]/) {print}\" in.txt > out.txt");
-
This is quite puzzling! Even I tried putting backslash within \Q and \E and using reverse quotes and exec() instead of system command. Got the same results :(