Whoopsie! Be wary of quoting NULLs. The program
listing has
$dbh->quote("NULL");
but that gives 'NULL', or the string NULL, rather
than the empty value NULL. To get the latter, use
$dbh->quote(undef);
...which works just fine if quoting a variable;
you get a quoted string when it contains a value,
and NULL when it's undef.