http://www.perlmonks.org?node_id=1041003


in reply to Getting information about a remote file via SSH: how to escape the filename

Net::OpenSSH can do it for you:
use Net::OpenSSH; my $ssh = Net::OpenSSH->new($remotehost, user => $remoteuser, password + => $remotepassword); $ssh->die_on_error("unable to connect to remote host"); my ($out, $err) = $ssh->capture2(ls => '-l', $remotefile);

Another option is to use SFTP:

use Net::SFTP::Foreign; use Data::Dumper; my $sftp = Net::SFTP::Foreign->new($remotehost, user => $remoteuser, password => $r +emotepassword, autodie => 1); my $attr = $sftp->stat($remotefile); print Dumper $attr;