Hi All!

GOAL: insert new text before at a minimum and after a block of text ideally.

I put data in a file like so:

while (<$RLOG>) { if (/(^Log Entry\s\d+:.*)/) { ++$recordcount; my $N = $1 .+ "\n\n"; my $e = <$RLOG>; my $x = <$RLOG>; my $t = <$RLOG>; my $l = <$RLOG>; my $n = <$RLOG>; my $s = <$RLOG> .+ "\n======================================== +==\n"; push @ary, ($N,$e,$x,$t,$l,$n,$s); } } for (@ary) { print $PLOG, $_; }
I am able to find any text entry "Alert Level 3" or higher, but then, I want to insert rtf code before this block of text and at the end of this block of text. I am failing on the insert before and insert after.
while(<$PLOG>) { ++$alert3orMoreCount if /^Alert Level\s0*(?:[3-9]|\d{2,})/i; $pos = $. if /^Alert Level\s0*(?:[3-9]|\d{2,})/i; }
I tried using splice like so:  splice( @ary, $pos, 0, $RTF{ctbl}, $RTF{red}, $RTF{ered} );

It seems silly to write the array data to a file, then try and manipulate it after. Below is the raw data file. Thank you!

__DATA__ Log Entry 14: 27 Feb 2011 10:03:42 Alert Level 2: Informational Keyword: Type-02 127002 1208322 Soft Reset Logged by: Baseboard Management Controller; Sensor: System Event 0x204D6A217E0200F0 FFFF027000120300 ========================================== Log Entry 13: 20 Feb 2011 08:33:42 Alert Level 2: Informational Keyword: Type-02 127002 1208322 Soft Reset Logged by: Baseboard Management Controller; Sensor: System Event 0x204D60D1E60200E0 FFFF027000120300 ========================================== Log Entry 12: 20 Feb 2011 07:14:27 Alert Level 4: TEST ALERT!!!!!!!!!!!!!!!! Keyword: Type-02 127002 1208322 Soft Reset Logged by: Baseboard Management Controller; Sensor: System Event 0x204D60BF530200D0 FFFF027000120300 ========================================== Log Entry 11: 13 Feb 2011 07:24:32 Alert Level 5: TEST ALERT!!!!!!!!!!!!!!!!!!!! Keyword: Type-02 127002 1208322 Soft Reset Logged by: Baseboard Management Controller; Sensor: System Event 0x204D5787300200C0 FFFF027000120300 ========================================== Log Entry 10: 06 Feb 2011 10:36:26 Alert Level 2: Informational Keyword: Type-02 127002 1208322 Soft Reset Logged by: Baseboard Management Controller; Sensor: System Event 0x204D4E79AA0200B0 FFFF027000120300 ==========================================

In reply to splice an array by dbs

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.