in reply to sed in perl: syntax error at script.pl line 19, near “;$'”

G'day rancho_trojan,

Welcome to the monastery.

There are multiple ways to run an external command from Perl: you need to show us exactly what code you used.

It sounds like you used some interpolating quoting mechanism (e.g. qx{sed ...}). If so, Perl will evaluate parts of the quoted string as variables (the ones I've spotted: $/, $' and $WX) and escape sequences (again, the ones I've spotted: \/ [twice] and \n). So, even when you eradicate all of Perl's syntax errors, you may just end up sending complete garbage to sed.

What you might be able to do (and I provide no guarantee this will work) is start with code like this:

print qq{sed ...};

Keep editing the ... part until the command you want is printed; then change print qq back to just qx and see if does what you want. Of course, that assumes you're using qx{}; although, you could probably do something similar for other scenarios.

From a Perl script, you'd probably be far better off using perl, rather than sed, to remove lines from a file. There are potentially many ways to do this: until we know about the data you're processing and in what context this processing occurs, we can't really advise you further on that.

Note that saying "I tried escaping $ but that dint help" does doesn't help us a whole lot. We don't know if you tried escaping one, some or all of the $ characters. We also don't know in what way, whatever you did, didn't help.

The guidelines in "How do I post a question effectively?" will help you formulate a question which we can answer immediately. Having to request formatting such that we can read your question [I didn't see the original], and then having to request all sorts of other information such that we can answer your question, doesn't really help anyone.

Update: s/does/doesn't/ (2nd to last paragraph). Thanks to Lotus1 for spotting this.

-- Ken