#Check for duplicate insert into database. if ($dbh->errstr()=~/SQL-23000/) { $template->param(duplicate => 1); }