#!/usr/local/bin/perl
while (<>)
{
  $accum .= $_;
  if (/^[45]/) {print $accum;}
  if (/^[2-5]/) {$accum = "";}
}
