use strict; my $trigger = -1; while (<>) { $trigger = $. + 2 if /^LUN 40\s*$/; print if $. == $trigger; }