don't go and try to quote the strings yourself.
Come on, why not? This is being a bit dogmatic, isn't it?
While I certainly agree that using the functionalities provided by DBI or other modules such as SQL::Abstract is a good idea (and I upvoted your post), knowing how to do it in core Perl is also a good idea, IMHO. After all, Perl is supposed to be a very good language at string handling. Do you really think that doing it the Java way is better?
For example:
my $str = join ', ', map { "'$_'" } split /,/, "CAT,DOG,BIRD,COW";
+ # -> 'CAT', 'DOG', 'BIRD', 'COW'
or even better:
my $str = "CAT,DOG,BIRD,COW";
$str =~ s/\b/'/g; # -> 'CAT','DOG','BIRD','COW'
Both examples took me less than 10 seconds to write and test (under the debugger). Looking up the documentation for either of the two modules would probably take me at least 10 or 15 minutes, so 60 to 100 times longer.
To me, using a module for something that can be done with a regex requiring less than ten keystrokes is a bit of over-engineering.
|