@arr = split /\|/; for (my $x = 0; $x < @arr; $x++) { if ($arr[$x] =~ m/\n/) { $arr[$x] = "\"".$arr[$x]."\""; } } $dbh->execute(@arr);