$threshold=25; foreach $variable (23..30) { if ($variable < $threshold) { $command = '/bin/cat'; $UPDATE = `$command << EOF $variable is the value from DB. $variable is less than $threshold EOF`; print "Update: '$UPDATE'\n"; } }