sub checkdb { foreach $_ (@_) { .. ... # snipped code where we munge around the db and get our ... # $variable if ($variable < $threshold) { $command = '/usr/bin/blah'; $UPDATE = `$command << EOF $variable is the value from DB. $variable is less that $threshold EOF`; } else { } } }