if($variable < $threshold) { my $command = '/usr/bin/blah'; my $updatestring = << "EOF"; $variable is the value from DB. $variable is less that $threshold EOF my $UPDATE = `$command $updatestring`; } else { ... } #### open ( COMMAND, " $command $updatestring | ") or die $!; while() { .... }