use strict; use warnings; my $flag = 0; while () { if (/^CHAN_TYPE\s+TCH/) { $flag = 1 } if ($flag) { if (/Px,Py/) { print; $flag = 0; } } } __DATA__