The good news is that perl is exactly the right way to do what you describe, and the task you describe is a good way to start learning perl.

The bad news: even if people were inclined to just provide the solution to your problem, without the very small amount of perl knowledge you would need to start solving it yourself, the chances of applying someone else's solution successfully are very slim.

So you'll have to do a bit more work, i'm afraid. but we can start things off. the sequence of events you need, at its simplest:

  • read a file into memory
  • remove whatever falls between your markers
  • write what remains of the file back to disk
  • So you need to learn about file input and output. The s/// operator will probably be the way to remove those parts you don't want, and you'll need to know a little about string matching and regular expressions to make that work. Then you'll just print what remains back to the same file (or another one).

    If you need to learn about the basics of perl and the structure of a simple script, you really need the camel book. Failing that, there are tutorials here and elsewhere.


    In reply to Re: script for removing certain text by thpfft
    in thread script for removing certain text by Anonymous Monk

    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.