use 5.010; for (split m/\n/, $str) { say if m/$regex/; }