Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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;


Comment on Re: net::ftp - reading a file
Download Code
Re^2: net::ftp - reading a file
by Anonymous Monk on Dec 21, 2006 at 13:06 UTC
    much appreciated, thanks

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://591084]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2014-12-29 08:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (185 votes), past polls