in reply to replacing carriage return line feed usinf chr()

How about letting DBI handle this instead?
my $dbh = DBI->connect( ... ); my $text = "aaaaa\nbbbb"; my $sql = $dbh->quote($text);
Or use placeholders on the fly:
my $sth = $dbh->prepare('insert into test(field1) values(?)'); $sth->execute($text);

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)