my $sql_ins_log = "insert into download_log (download_id,status,update_time)" . " values(?,getValueByMeaning('$status_meaning','17'),?)"; #### my $sql_ins_log = "insert into download_log (download_id,status,update_time)" . " values(?,?,?)"; foreach(@X){ $now = localtime->mysql_datetime; $sth = $dbh->prepare($sql_ins_log); $sth->execute($download_id,getValueByMeaning('$status_meaning','17'),$now); } #### insert into download_log (download_id,status,update_time) values(1,getValueByMeaning('DONE',17'),'2014-09-15 14:16:00')