in reply to Accessing files on another server within perl script
G'day vihar,
Welcome to the monastery.
'This is what I originally had to access these files on the same server:
@files = glob "/mmk1/rdd/load/file.txt"'
I don't know what this is supposed to tell us; perhaps some further explanation was omitted. In list context (as you have here), glob performs filename expansion on the expression provided; as you have no wildcards, all this does is:
$ perl -Mstrict -Mwarnings -le ' my @files = glob "/mmk1/rdd/load/file.txt"; print "@files"; ' /mmk1/rdd/load/file.txt
"I can't write Perl scripts on that server because all my Perl modules are installed on the old server. Is there a way to solve this issue?"
You can add a coderef hook to @INC (see perlvar: General Variables) that may be able to do this for you. See require for details; the basic idea is to do something like this (completely untested):
push @INC, \&get_remote_module; sub get_remote_module { my ($coderef, $filename) = @_; open my $module_fh, '-|', "<$filename transfer command>" or die "m +esg: $!"; return $module_fh; }
where "<$filename transfer command>" might be (simplistically) "curl scheme://your.domain/perl/lib/path/$filename".
Update: fixed typo s/sub get_remote_modue/sub get_remote_module/
-- Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Accessing files on another server within perl script
by vihar (Acolyte) on Aug 16, 2013 at 14:31 UTC | |
by marto (Cardinal) on Aug 16, 2013 at 14:44 UTC |