Hello, I have to do Perl script, that take a log file on input. Every line of the log-file is structured like this:
Line2-16042010083153^Sistema Monitoraggio Centauro^01032491^^^2GbNLLGN +mMK1wpPt2HLxCXXW8DmWc5V6JQSk7wZNdq6NnGmlXGnJ!-1562333788!127139950109 +2
But sometimes the log-file has some irregular lines:
Line3-16042010084016^Rete Prova Centauro^01032491^Analisi giornaliera +Mensile^dataFinale = 13/04/2010|tecnica = ITALTEL|livelloImpianto = 1 +|dataIniziale = 13/04/2010|direzioneTraffico = |livelloOLOFascioITC = + 2|iqSoglia = 0.05|livelloFascioITC = 3|areaTerritoriale = PV|impiant +iSel = |livelloDirezioneTraffico = 4|oloFascioITCSel = |livelloQuarto +Dora = 5|action = agmDrillDownData^2GbNLLGNmMK1wpPt2HLxCXXW8DmWc5V6JQ +Sk7wZNdq6NnGmlXGnJ!-1562333788!1271399501 Line4-92
I have to manage these irregular situations so in output I'll have just one line (merge Line3 and Line4). This is the code of my script:
while($line=<STDIN>){ chomp($line); if($line=~/^\d{14}^.*^.*^.*^.*^\Z([^\d+!\d+])/){ print $line."\n"; } else { $line2=<STDIN>; chomp($line2); print "$line$line2\n"; redo; } }
Thanks in advance for the help!!!!

In reply to STDIN Log Parser by DesperatePerler

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.