in reply to How to act upon lines between two other lines in file?

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