my $hot; while () { $hot=1 if /^internal name/; if ( /^need this/ && $hot) { print; } }