Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I set out to try something a bit different and ended up doing pretty much what jlongino described above. Nothing very clever, except maybe that as (mostly) your data appears to be fixed-format records. You can greatly simplify your regexes by first chopping the lines up using unpack.

The following code uses (simplified) mocked-up data and will need some considerable work, but it does show the basic technique, and may be of some use as a starting point.

#! perl -sw use strict; my %info; while (<DATA>) { my ($partn, $msg, $timestamp ) = unpack 'x4 A2 x6 A63 A19', $_; $info{$partn}{started}= $timestamp, $info{$partn}{job} = $1 if $msg =~ m!^// JOB (.{8})!; print 'Job ', $info{$partn}{job}, ' started in partition ', $partn, ' at ', $info{$partn}{started}, $/, ' and finished at ', $timestamp, ' with a return code of ', $1, $/ if $msg =~ m!^EOJ.+?MAX.RETURN CODE=(\d{4})! ; } =pod #Output c:\test>206952 Job NEQZQCPB started in partition P1 at 07:56:18 10/22/200 and finished at 08:21:51 10/22/200 with a return code of 0001 Job HGPKIOEV started in partition ZK at 08:58:19 10/22/200 and finished at 07:56:05 10/22/200 with a return code of 0002 Job SPZDIAGL started in partition Q1 at 08:39:12 10/22/200 and finished at 09:00:33 10/22/200 with a return code of 0003 Job QMGPMPQK started in partition BG at 08:30:41 10/22/200 and finished at 08:01:53 10/22/200 with a return code of 0004 Job DZCWQXCS started in partition BG at 08:42:35 10/22/200 and finished at 08:05:12 10/22/200 with a return code of 0004 Job EDQYPSEG started in partition AX at 09:06:46 10/22/200 and finished at 08:22:15 10/22/200 with a return code of 0001 Job BXVWTNMB started in partition Q1 at 07:58:45 10/22/200 and finished at 07:55:04 10/22/200 with a return code of 0003 Job ZFWYJVRT started in partition BG at 08:43:40 10/22/200 and finished at 09:04:00 10/22/200 with a return code of 0000 Job SSJYBRLY started in partition AX at 08:08:56 10/22/200 and finished at 07:57:29 10/22/200 with a return code of 0001 c:\test> =cut __DATA__ 000 Q1 0897 // JOB SPZDIAGL + 08:39:12 10/22/2002 001 Q1 0652 MSG001 SPZDIAGL + 08:26:24 10/22/2002 002 ZK 0229 // JOB HGPKIOEV + 08:58:19 10/22/2002 003 AX 0108 // JOB EDQYPSEG + 09:06:46 10/22/2002 004 ZK 0735 MSG001 HGPKIOEV + 08:57:16 10/22/2002 005 AX 0218 MSG001 EDQYPSEG + 08:42:01 10/22/2002 006 P1 0345 // JOB NEQZQCPB + 07:56:18 10/22/2002 007 P1 0735 EOJ NEQZQCPB MAX.RETURN CODE=0001 + 08:21:51 10/22/2002 008 ZK 0973 MSG002 HGPKIOEV + 07:56:08 10/22/2002 009 Q1 0317 MSG002 SPZDIAGL + 08:47:36 10/22/2002 010 ZK 0945 EOJ HGPKIOEV MAX.RETURN CODE=0002 + 07:56:05 10/22/2002 011 Q1 0349 MSG003 SPZDIAGL + 08:02:11 10/22/2002 012 BG 0903 // JOB QMGPMPQK + 08:30:41 10/22/2002 013 AX 0872 MSG002 EDQYPSEG + 07:55:13 10/22/2002 014 AX 0931 MSG003 EDQYPSEG + 08:09:46 10/22/2002 015 Q1 0697 EOJ SPZDIAGL MAX.RETURN CODE=0003 + 09:00:33 10/22/2002 016 Q1 0470 // JOB BXVWTNMB + 07:58:45 10/22/2002 017 BG 0856 MSG001 QMGPMPQK + 08:18:55 10/22/2002 018 BG 0625 MSG002 QMGPMPQK + 07:57:50 10/22/2002 019 BG 0753 MSG003 QMGPMPQK + 09:08:36 10/22/2002 020 BG 0188 MSG004 QMGPMPQK + 08:36:16 10/22/2002 021 BG 0639 EOJ QMGPMPQK MAX.RETURN CODE=0004 + 08:01:53 10/22/2002 022 BG 0766 // JOB DZCWQXCS + 08:42:35 10/22/2002 023 AX 0729 MSG004 EDQYPSEG + 08:37:13 10/22/2002 024 BG 0509 MSG001 DZCWQXCS + 08:17:23 10/22/2002 025 BG 0276 MSG002 DZCWQXCS + 07:55:58 10/22/2002 026 Q1 0581 MSG001 BXVWTNMB + 08:30:49 10/22/2002 027 BG 0553 MSG003 DZCWQXCS + 09:09:26 10/22/2002 028 BG 0473 EOJ DZCWQXCS MAX.RETURN CODE=0004 + 08:05:12 10/22/2002 029 AX 0925 EOJ EDQYPSEG MAX.RETURN CODE=0001 + 08:22:15 10/22/2002 030 Q1 0985 MSG002 BXVWTNMB + 08:49:00 10/22/2002 031 Q1 0292 EOJ BXVWTNMB MAX.RETURN CODE=0003 + 07:55:04 10/22/2002 032 BG 0004 // JOB ZFWYJVRT + 08:43:40 10/22/2002 033 BG 0136 MSG001 ZFWYJVRT + 09:13:00 10/22/2002 034 AX 0547 // JOB SSJYBRLY + 08:08:56 10/22/2002 035 BG 0476 MSG002 ZFWYJVRT + 08:28:15 10/22/2002 036 AX 0671 MSG001 SSJYBRLY + 07:56:40 10/22/2002 037 BG 0207 MSG003 ZFWYJVRT + 08:10:07 10/22/2002 038 BG 0275 EOJ ZFWYJVRT MAX.RETURN CODE=0000 + 09:04:00 10/22/2002 039 AX 0808 EOJ SSJYBRLY MAX.RETURN CODE=0001 + 07:57:29 10/22/2002

Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!

In reply to Re: Daily Log Audit (regex issue) by BrowserUk
in thread Daily Log Audit (regex issue) by blacksmith

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2022-01-20 14:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (56 votes). Check out past polls.

    Notices?