Hello all, I just started learning Perl and I get stuck on a basic file processing :

I have to convert a file format, the program should read a input file and after processing (which counts the number of each term in each group, see below), yield a output file. Here is the format of the input file:

Group1: somo|112345478 somo|734567233 homo|233689876

Group2: somo|904686712 somo|891145662 somo|106736432

Group3: aomo|397634567 aomo|123446789

Group4: aomo|905672345 aomo|120846789

........

..

From the above input, the output file should look like (the numbers after the pipe should not be considered):

somo homo aomo

Group1 2 1 0

Group2 3 0 0

Group3 0 0 2

Group4 0 0 2

I get stuck on this file conversion for sometime now and unable to figure it out. Any guidance is highly appreciated. Thanks in advance.. Apologies if this post doesn't belong here...


In reply to Need help in file processing by utpalmtbi

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.