#how it currently works for (@arr) { print "$_\n" if /pattern/; } #what I'm suggesting print "$_\n" if /pattern/ for @arr;