# this line runs fine $server->exec("sudo rm -r /directory/*"); # exec is wrapper for the Net::OpenSSH "system" method # checks if directory exists. This line causes Net::OpenSSH to crap out in special circumstances. my $value = $server->capture(qq#perl -e "print (-d '/directory/')"#); # returns 1 because dir exists print $value;