Discussion in 'Perl Misc' started by kj, May 6, 2014.

  1. kj

    kj Guest

    I'm looking for the "moral equivalent" of the (fictitious) `openremote`
    function below:

    my $handle = openremote( '' ) or die $!;
    while ( <$handle> ) {
    # etc.
    # do stuff with $_
    close $handle;

    IOW, I'm looking for a way to open a read handle to a remote file
    so that I can read from it *line-by-line*. (Typically this file
    will be larger than I want to read all at once into memory. IOW,
    I want to avoid solutions based on stuffing the value returned into
    LWP::Simple::get into an IO::String.)

    I'm sure this is really basic stuff, but I have not been able to
    find it after a lot of searching.


    kj, May 6, 2014
    1. Advertisements

  2. kj

    Jim Gibson Guest

    You cannot read a file on a remote system line-by-line, barring NFS or
    other file distribution system that mimics a local file system from a
    remote system. The normal ways to read such a file are:

    1. Download the remote file to your local system and read the copy.

    2. Open a socket to the remote system and read the socket (but not
    exactly a line-oriented protocol). This assume a cooperative socket
    server on the remote system that will read the file and provide its
    contents to you over the connected socket.

    FTP and HTTP are two protocols that provide these services. They both
    can be used from a Perl program. See the Net::FTP and LWP::UserAgent
    modules. They both assume a corresponding service on the remote
    Jim Gibson, May 7, 2014
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
There are no similar threads yet.