use strict; use warnings; my $print_flag = 'N'; while () { if ($print_flag eq 'Y') { print; $print_flag = 'N'; } $print_flag = 'Y' if m/^Customer ID: Yes/; } __DATA__ Customer ID: none VT : 002/89 Customer ID: Yes VT: 001/89 Customer ID: none VT: 006/85 Customer ID: Yes VT: 003/56