From: Fergal Daly (fergal at domain esatclear.ie)
Date: Thu 04 May 2000 - 13:18:32 IST
Last mail got caught by the spamtrap and still hasn't come in, so here a
solution that doesn't involve selecting data from the table at all. Don't
forget to fill in the blanks, also you will want to adjust the valid chars
regex and possibly the limits of the loop and of course uncomment the sql
executor,
Fergal
#! /usr/bin/perl
use strict;
use DBI;
my $db_name = "";
my $host_name = "";
my $username = "";
my $passwd = "";
my $offending_field_name = "";
my $table_name = "";
my $dbh = DBI->connect(
'DBI:mysql:database=$db_name;host=$host_name',
$username,
$passwd,
{
RaiseError => 1,
AutoCommit => 1,
}
);
my $chars = '';
foreach my $val (32..127)
{
$chars .= chr($val);
}
$chars =~ s/[\w\d]//g; # get rid on non-nasty chars
foreach my $nasty (split("", $chars))
{
my $nasty = $dbh->quote($nasty);
my $sql = "UPDATE $table_name
SET $offending_field_name = replace($offending_field_name, $nasty)";
print "$sql\n";
# $dbh->execute($sql);
}
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:06:01 GMT