sub writeElems { my ($tbl, $prm, $dbh) = (shift, shift, shift); #table name, CGI object, DBI connection. my %valid = preinsert($prm, $tbl); #Creates the hash if (%valid) { $dbh->do(insertstr($tbl, %valid)); } #Creates and execs the statement return %valid; }