#!/usr/bin/perl use warnings; use strict; update_table( 'test_name', 'test_phone', 'test_city', 'test_country' ); update_table( 'test_name', 'test_phone', '', 'test_country' ); update_table( 'test_name', '', 'test_city', '' ); sub update_table { my ($name, $phone, $city, $country) = @_; my $sql = qq! UPDATE table SET ! . qq! phone = '$phone', ! . qq! city = '$city', ! . qq! country = '$country' ! . qq! WHERE name = '$name' !; print $sql; return 1; } #### UPDATE table SET phone = 'test_phone', city = '', country = 'test_country' FROM ... #### UPDATE table SET phone = 'test_phone', country = 'test_country' FROM ...