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

Your problem seems similar to one answered by tachyon in Re: Formatting questions. His example code slurps in all the lines from the file at once and then splits on the leading pattern, something like this:
use strict; undef $/; my $data = <>; my @data = split 'checking', $data; shift @data; my @bad_files; for my $bit (@data) { my ($file_name) = $bit =~ /file <([^>]+)>/; push @bad_files, $file_name if ($bit =~ /media does not exist/); }