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


In reply to Re: Accessing files on another server within perl script by kcott
in thread Accessing files on another server within perl script by vihar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.