hi,
good morning,

I've done one program to read this file, please refer as below:

NAME SUM ITEMS_A ITEMS_B ITEMS_C BAA 1 1348396499 134000 BAA 10 1333333333 002333 ITC 9 1340014296 181818 ITC 10 1349999999 134110 BAA 29 1346512572 181919 BAA 100 1349990990 * FAC 3 1346048490 134795 122233 FAC 10 1346666655 181919 130303 BAB 9 1345100000 181919 ...
But, there are too long and not very good. So, anybody knows how to make it easier and simple. The program algorithm are:
If NAME =~ /BAA/ if ITEMS_A =~ /^134/ AND ITEMS_B =~ /^134/ THEN TBAA+=SUM a++; elsif ITEMS_A =~ /^134/ AND ITEMS_B !~ /^(134|00)/ THEN OBAA+=SUM b++; elsif ITEMS_A =~ /^134/ AND ITEMS_B =~ /^00/ THEN IBAA+=SUM ab++; else EBAA+=SUM c++; elsif NAME =~ /ITC/ if ITEMS_A =~ /^134/ AND ITEMS_B =~ /^134/ THEN TITC+=SUM d++; elsif ITEMS_A =~ /^134/ AND ITEMS_B !~ /^134/ THEN OITC+=SUM e++; else EITC+=SUM f++; elsif NAME =~ /FAC/ if ITEMS_A =~ /^134/ AND ITEMS_B =~ /^134/ THEN if ITEMS_C !~ /130303/ THEN TFAC+=SUM g++; else TXFAC+=SUM h++ elsif ITEMS_A =~ /^134/ AND ITEMS_B !~ /^134/ THEN if ITEMS_C !~ /130303/ THEN TYFAC+=SUM i++; else TZFAC+=SUM j++ else if ITEMS_A =~ /^134/ AND ITEMS_B =~ /^134/ THEN UNK+=SUM k++; elsif ITEMS_A =~ /^134/ AND ITEMS_B !~ /^134/ THEN UNK2+=SUM l++; else UNK3+=SUM m++;
finally, print all the result by following the NAME, as example:
NAME TOTAL_SUM TOTAL BAA (134->134) 140 5 (134->other) 123 4 (134->00???) 20 1 (134->unknown) 0 0 ITC (134->134) 100 10 (134->other) 30 4 (134->unknown) 0 0 FAC (134->134->130303) 30 3 (134->134->other) 90 4 (134->other->130303) 60 2 (134->other->other) 1 1 OTH (134->134) 10 1 (134->other) 9 1 (134->unknown) 1 1

20030717 Edit by jeffa: Changed title from 'how to make it easier ?'


In reply to Help with simplifying file parsing program? by bh_perl

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.