in reply to DBD::AnyData delete rows

You should replace
my $ret = $dbh->do($sql);
with
my $ret = $dbh->do($sql) or die $dbh->errstr;

The delete could be failing for any of a dozen reasons, all on the database side. (You should make similar changes for all other DBI calls, as well.)