This is along the same lines as the other posts above. But more along the style I think you were asking for. (as noted by the node in your question. Anyhow, as the above it assumes that the checking image file lines come in pairs and that the only difference is the .f in the latter in the pair. It also assumes that media does not exist is the last thing on the line. Anyhow here is the code (Data tested with after __DATA__ and results after __END__ ):
use strict; use warnings; my @records; my $media_existance = "Media does exist"; my $temp1 = 0; while ( <DATA> ) { if ( /^checking image file <(.*)>/ .. /(.*<$temp1\.f>)/ ) { $temp1 = $1; if ( $temp1 =~ /^checking/ ) { push @records, [$temp1,$media_existance]; $media_existance = "Media does exist"; } elsif ( /media does not exist$/ ) { $media_existance = "Media doe +s not exist" } } } foreach (@records) { print join ":",@$_; print $/; } __DATA__ checking image file <NT-Development_1024371281_FULL> >copy 1 frag 1 media CC0202 host netbackup2: media does not exist >copy 1 frag 2 media CC0202 host netbackup2: media does not exist >copy 1 frag 3 media CC0202 host netbackup2: media does not exist >copy 1 frag 4 media CC0202 host netbackup2: media does not exist >copy 1 frag 5 media CC0202 host netbackup2: media does not exist checking files file <NT-Development_1024371281_FULL.f> checking image file <NT-Development_1024371282_FULL> checking files file <NT-Development_1024371282_FULL.f> checking image file <NT-Development_1024371283_FULL> checking files file <NT-Development_1024371283_FULL.f> checking image file <NT-Development_1024371284_FULL> >copy 1 frag 1 media CC0202 host netbackup2: media does exist >copy 1 frag 2 media CC0202 host netbackup2: media does exist >copy 1 frag 3 media CC0202 host netbackup2: media does not exist >copy 1 frag 4 media CC0202 host netbackup2: media does exist >copy 1 frag 5 media CC0202 host netbackup2: media does exist checking files file <NT-Development_1024371284_FULL.f> checking image file <NT-Development_1024371285_FULL> >copy 1 frag 1 media CC0202 host netbackup2: media does exist >copy 1 frag 2 media CC0202 host netbackup2: media does exist >copy 1 frag 3 media CC0202 host netbackup2: media does exist >copy 1 frag 4 media CC0202 host netbackup2: media does exist >copy 1 frag 5 media CC0202 host netbackup2: media does exist checking files file <NT-Development_1024371285_FULL.f> checking image file <NT-Development_1024371286_FULL> >copy 1 frag 1 media CC0202 host netbackup2: media does not exist >copy 1 frag 2 media CC0202 host netbackup2: media does exist >copy 1 frag 3 media CC0202 host netbackup2: media does exist >copy 1 frag 4 media CC0202 host netbackup2: media does exist >copy 1 frag 5 media CC0202 host netbackup2: media does exist checking files file <NT-Development_1024371286_FULL.f> __END__ checking files file <NT-Development_1024371281_FULL.f>:Media does not +exist checking files file <NT-Development_1024371282_FULL.f>:Media does exis +t checking files file <NT-Development_1024371283_FULL.f>:Media does exis +t checking files file <NT-Development_1024371284_FULL.f>:Media does not +exist checking files file <NT-Development_1024371285_FULL.f>:Media does exis +t checking files file <NT-Development_1024371286_FULL.f>:Media does not +exist

-enlil


In reply to Re: How to act upon lines between two other lines in file? by Enlil
in thread How to act upon lines between two other lines in file? by blink

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.