Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: net::ftp - reading a file

by imp (Priest)
on Dec 21, 2006 at 12:41 UTC ( #591084=note: print w/replies, xml ) Need Help??

in reply to net::ftp - reading a file

Net::FTP's documentation says:
Get REMOTE_FILE from the server and store locally. LOCAL_FILE may be a filename or a filehandle. If not specified, the file will be stored in the current directory with the same leafname as the remote file

To skip the local file you can provide a filehandle that writes to a scalar instead, like this:

#!/usr/bin/perl use strict; use warnings; use Net::FTP; my $home="localhost"; my $username="user"; my $password="password"; my $filename='file.txt'; my $file_data; # $newfile uses $file_data as the backend storage, and is opened read/ +write. open my $newfile, '+>', \$file_data; my $ftp = Net::FTP->new("$home") or die "Can't connect: $@\n"; $ftp->login($username, $password) or die "Couldn't login\n"; $ftp->get($filename, $newfile) or die "Couldn't get $filename\n"; print $file_data;

Replies are listed 'Best First'.
Re^2: net::ftp - reading a file
by Anonymous Monk on Dec 21, 2006 at 13:06 UTC
    much appreciated, thanks

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://591084]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2018-05-25 17:37 GMT
Find Nodes?
    Voting Booth?