# Reading from a prepopulated array my @wanted; foreach my $line ( @input ) { push $line, @wanted if $line =~ /^SELECT poid/; }