G'day lddzjwwy,

The problem with your code is that ".*" matches zero or more characters; thus, "/^<(.*)/" matches "<" and "<xxx;".

Here's a barebones script that captures the data you want. I'll leave you to format the output however you want it.

#!/usr/bin/env perl use strict; use warnings; my $re = qr{^<(.+);}; while (<DATA>) { if (/$re/) { print_log_entry_header($1); } else { print; } } sub print_log_entry_header { print "*** Log Entry: @_ ***\n"; } __DATA__ <syrip:survey; ORDERED < EX-A 9UCIE6CG0CL235_____D331 AD-12 TIME 130429 1428 PAGE 1 SOFTWARE RECOVERY SURVEY EVENT TYPE EXPLANATION EVENTCNT FRDE +L 8 FORLOPP MANUALLY INITIATED FORLOPP RELEASE +1 7 LARGE OTHER-EEDWL 6 LARGE OTHER-STARTUP 5 LARGE INIT START/RESTART AFTER INIT START EVENT CODE INF1 INF2 INF3 INF4 SIDE STATE DATE TIME AC +T 8 H'310C H'0000 H'0F98 H'0001 H'0000 A SINGLE 130116 153704 NO 7 H'9003 H'000A H'0000 H'0000 H'0000 B SINGLE 120912 113918 NO 6 H'9003 H'000A H'0000 H'0000 H'0000 B SINGLE 120906 090851 NO 5 H'9004 H'0000 H'0000 H'0000 H'0000 B SINGLE 120905 171355 NO END EX-A 9UCIE6CG0CL235_____D331 AD-12 TIME 130429 1428 PAGE 1 <sastp; ......

Output:

$ pm_custom_file_split.pl *** Log Entry: syrip:survey *** ORDERED < EX-A 9UCIE6CG0CL235_____D331 AD-12 TIME 130429 1428 PAGE 1 SOFTWARE RECOVERY SURVEY EVENT TYPE EXPLANATION EVENTCNT FRDE +L 8 FORLOPP MANUALLY INITIATED FORLOPP RELEASE +1 7 LARGE OTHER-EEDWL 6 LARGE OTHER-STARTUP 5 LARGE INIT START/RESTART AFTER INIT START EVENT CODE INF1 INF2 INF3 INF4 SIDE STATE DATE TIME AC +T 8 H'310C H'0000 H'0F98 H'0001 H'0000 A SINGLE 130116 153704 NO 7 H'9003 H'000A H'0000 H'0000 H'0000 B SINGLE 120912 113918 NO 6 H'9003 H'000A H'0000 H'0000 H'0000 B SINGLE 120906 090851 NO 5 H'9004 H'0000 H'0000 H'0000 H'0000 B SINGLE 120905 171355 NO END EX-A 9UCIE6CG0CL235_____D331 AD-12 TIME 130429 1428 PAGE 1 *** Log Entry: sastp *** ......

-- Ken


In reply to Re: Read in the logfile by kcott
in thread Read in the logfile by lddzjwwy

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.