Author image David Muir Sharnoff
and 1 contributors


File::Slurp::Remote::SmartOpen - open files locally or remotely automatially


 use File::Slurp::Remote::SmartOpen;

 smartopen($file, $fd, $mode);


This module provides one function: smartopen($file, $fd, $mode). The function looks at the filename. If it has a colon in it, then it assumes that what comes before the colon is a hostname. If that hostname is not the hostname of the local system, it uses ssh to get to the remote system to open the file.

If the filename ends with .gz or .bz2, then it will pipe the input (or output) though zcat or bzcat (gzip or bzip2) as it opens the file.

The mode can be r or w. It defaults to read.

By default, remote files are accessed with

 ssh -o StrictHostKeyChecking=no

You can override that by redefining $File::Slurp::Remote::SmartOpen::ssh.


 smartopen("host1:/etc/passwd", my $fd, "r");


This package may be used and redistributed under the terms of either the Artistic 2.0 or LGPL 2.1 license.