my $cmd = Generate_Command($arg1,$arg2); $ssh->cmd($cmd); $cmd = Generate_Another_Command($arg1,$arg2); $ssh->cmd($cmd);