in reply to File test on remote machine and mkpath

Hope this snippet would help,
my $g_cmd="ssh Machinename ls <completefilepath>"; `$g_cmd`; if($?) { print "Error doesnot exist"; } else { $g_cmd="scp local_file remotehost:targetdirectory/remote_file"; `$g_cmd`; }
if it's a directory you want to test add -d switch to the ls command.

The world is so big for any individual to conquer