I can't quite make out how you got the output from the input you provided. Maybe I'm just not seeing something obvious, but the rules that applied to the input to produce the output aren't clear to me. So I'll just offer some links that may be of help to a self-described newbie.

The perlretut Perl regular expression tutorial might be of some help. Also, I'm not sure of how new a newbie you are, but the perlopentut should help you get the file open, if you need that. Once you get the file open you can go through it's contents and use regular expressions to match text based on the rules you provide, and manipulate the text as needed.

Those articles are both at http://perldoc.perl.org - you might find the rest of the site helpful as well if you need a good reference.

Also, depending on where you work/study you might have access to Safari, an online service with electronic copies of a ton of good tech books. The O'Riely Perl books are quite good, and might be helpful. 'Programming Perl' was very useful and sat on my desk for a long time while I was learning Perl.

Sorry I couldn't offer anything more specific. Hopefully those will help.


In reply to Re: Parsing and Modifying a flat file in perl by eighty-one
in thread Parsing and Modifying a flat file in perl by ad23

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.