I am unable to avoid the comment lines(lines starting with *) for parsing during string replacement in a file. Please help me with my code.
`perl -pi.bak -e "$_ =~/[#.*]*/; /s/PATTERN/REPLACEMENT STRING/g" Test.txt`;
Am using Perl in Eclipse,Windows XP.
I get the following Error message:
Number found where operator expected at -e line 6, near "* LAST UPDATED 09/15"
(Might be a runaway multi-line // string starting on line 1)
(Missing operator before 15?)
Bareword found where operator expected at -e line 6, near "1994 AT"
(Missing operator before AT?)
Thanks in Advance,
Perl Newbie
use
nextto skip the following code if you match a comment:update: now as choroba suggested, instead of launching a separate instance of Perl and having to deal with quotes, you should probably have the whole thing in your main code:
Note that
$func[5]can (potentially) includes meta-characters, so I used\Qand\Eto escape them.I am not sure about the
\[\.\]*part, which as written matches a square bracket, a dot, and 0 or more closing square brackets:[.,[.], or[.]]. I suspect that’s not what you want.