my @winners = grep /prefix$part/, @list; #### while (<>) { next unless /prefix$part/; ... }