If you set $/ to "" you will read paragraphs at a time. That is, you will read a block of lines that are separated by 1 or more blank lines. Then you can split on newline boundaries:
$/ = ""; # read paragraphs
while (my $para = <>)
{
my $lastHeading;
my @lines = split(/\n/, $para);
if (@lines == 1) # heading?
{
$lastHeading = $lines[0];
next;
}
my $hitMe;
if ($lastHeading eq 'MEANINGLESS TEXT')
{
$hitMe = $lines[4]; # fifth line
}
elsif ($lastHeading eq 'ALTERNATIVE TEXT')
{
$hitMe = $lines[5]; # sixth line
}
# now do something...
}