$dbh->prepare(" insert into user_master (msisdn,cat0,cat1,cat2,cat3,cat4,cat5,cat6,cat7,vip,SAcode,phone_type) values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) on duplicate key update cat0=?, cat1=?, cat2=? "); # ^^^ etc. #### $db_update_cmd = $db_update_cmd."cat$cat=1,"; #### $db_update_cmd .= "cat$cat=1,"; #### if ( $preference =~ tr/0//) #### if ( $preference =~ /0/ ) # should be a more robust regexp to only capture '0', this is just to show the right operator