| 1 | package File::Slurp::Remote; | ||||||||||
| 2 | |||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 3 | ▶ | use File::Slurp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 3 | require Exporter; | |||||||||
| 7 | 3 | ▶ | use File::Slurp::Remote::SmartOpen; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 3 | our @ISA = qw(Exporter); | |||||||||
| 10 | 3 | our @EXPORT = (@File::Slurp::EXPORT, qw(write_remote_file read_remote_file)); | |||||||||
| 11 | |||||||||||
| 12 | 3 | our $VERSION = '0.48'; | |||||||||
| 13 | |||||||||||
| 14 | # Unused: retained so that code which sets it doesn't break | ||||||||||
| 15 | 3 | our $scp = "scp -q -o StrictHostKeyChecking=no -o BatchMode=yes -o PasswordAuthentication=no"; | |||||||||
| 16 | |||||||||||
| 17 | sub write_remote_file | ||||||||||
| 18 | 2 | ▶ | { | ||||||||
|
Subroutine
write_remote_file: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||
| 19 | 2 | my $host = shift; | |||||||||
| 20 | 2 | my $file = shift; | |||||||||
| 21 | |||||||||||
| 22 | 2 | my $fd; | |||||||||
| 23 | 2 | smartopen("$host:$file", $fd, "w"); | |||||||||
| 24 | 2 | ▶ | (print $fd @_) or die "write to $host:$file: $!"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 2 | ▶ | close($fd) or die "close $host:$file: $!"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | sub read_remote_file | ||||||||||
| 29 | 10 | ▶ | { | ||||||||
|
Subroutine
read_remote_file: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 30 | 10 | my $host = shift; | |||||||||
| 31 | 10 | my $file = shift; | |||||||||
| 32 | |||||||||||
| 33 | 10 | my $fd; | |||||||||
| 34 | 10 | smartopen("$host:$file", $fd, "r"); | |||||||||
| 35 | 6 | ▶ | if (wantarray) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 1 | return <$fd>; | |||||||||
| 37 | } else { | ||||||||||
| 38 | 5 | return join('', <$fd>); | |||||||||
| 39 | } | ||||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 3 | 1; | |||||||||
| 43 | |||||||||||
| 44 | __END__ | ||||||||||