foreach my $try (@array2) { $try =~ /^(.*),"(.*)",(.*),(.*),"(.*)"/s or die "Malformed input data: >>$try<<"; ... };