exodist has asked for the wisdom of the Perl Monks concerning the following question:
ok, I am writing a few programs in perl that make use of mysql databases, in several of them I have to deal with files or file contents (text) that contain every character on the table. So now I have 2 questions:
1) is there any utility subroutine that will properly format a string for the mysql insert within 'single quotes', I have tried my own escape subroutines, they work most of the time, but I have so many files and possible cases that I have just about given up on my own cleaning subroutine. -If this subroutine does not exist then is there one that can change the contents of a scalar changing non a-z0-9 characters into something else like hex codes (maybe through CGI) so that I can then re-convert them when I pull the data out of the database?
2) These problems cause the whole script to die w/ a mysql error. I want a way to have the script realize the error occured and just move on to the next file the script will process then make the next entry, etc. I tried using eval but it still closed the script upon error. - In the stuff I am working on in this case having every single entry work is not critical.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl DBD::mysql - Clean a scalar, keep running after error.
by chargrill (Parson) on Feb 07, 2007 at 03:45 UTC | |
by exodist (Monk) on Feb 07, 2007 at 04:37 UTC | |
|
Re: Perl DBD::mysql - Clean a scalar, keep running after error.
by glasswalk3r (Friar) on Feb 07, 2007 at 19:40 UTC |