in reply to grabbing N lines after matching one?

This is completely untested and I'm sure a lot more wordy than it needs to be, but I'm tired and didn't feel especially graceful :^).
my $cntr = 0 my $stuff = "" LINE: while(<HTMLFILE>) { if($cntr == 0 && $_ !~ /$myregex/) { next LINE; } last LINE if $cntr >= 5; $stuff .= $_; $cntr++; }