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


In reply to Re: sed in perl: syntax error at script.pl line 19, near “;$'” by kcott
in thread sed in perl: syntax error at script.pl line 19, near “;$'” by rancho_trojan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.