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);
}
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!