use List::Util qw( first ); my $keeper = first { /^Line 3 : / } @lines;