Hello Monks,

I have a large input file, in which I have to comment out a few lines. It is a pain to do it manually, so I wanted to write a script to do it.

So here is what I have:

The block of line which I want to comment out start with a TAG, and end with a ");". For example:

MYTAG (
Line 1
Line 2
Line 3
);

So, the block of lines would start with a tag and end with ");" And there can be amny block of lines like these, ofcourse each with an individual starting TAG

My question is how will I read just the required lines between the TAG and the closing bracket and then just comment out those lines in the input.

Effectively, the above lines in the input text need to be changed to:

#MYTAG (
# Line 1
# Line 2
# Line 3
# );

Please provide some wisdom..

Thank you all great Monks,

A learning Monk!


In reply to How to comment out lines in a text? by ginju75

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.