I have been asked to develop a script that parses the output of a command that reads a binary log file(and outputs it in text).
The output is comprised of several records, and each record is in the following format:
Packet ID (hex)     0xF040            Origin           DOS 7452
Date (mm/dd/yyyy)   09/07/2001        Qualifier        ACS
Time                15:45:45.90       Terminal ID      109
Device ID (hex)     0x2D0             Application ID   SALESAPP
Catalog Code        DOS               Function ID(hex) 0x800E
Status              253               Severity         0
Item code 772788600047 was not found in the PLU file
------------------------------------------------------------
The above format will remain the same, but the overall number of records will change on a day to day basis. What I need to do is grab the records for just a specific day, then break that down to just a few specific records based upon the information in the last line before the separator. Below is some preliminary code that I have done:
#!/usr/bin/perl -w use strict; #This is the command I need to run my @Command = `ulread`; my $line; my @stripped=(); # Get rid of the separators and put everything into # another array foreach $line(@Command){ if($line=~/^-+$/){}else{ push @stripped,$line; } } # The end of the array will have 4 lines that are not part # of any record (it is actually statistical info for the # entire display). These lines can be removed. for(1..4){ pop @stripped; }
Does anyone here have any better ideas than this? Thanks.

TStanley
--------
There's an infinite number of monkeys outside who want to talk to us
about this script for Hamlet they've worked out
-- Douglas Adams/Hitchhiker's Guide to the Galaxy

In reply to Log File Parsing by TStanley

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.