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;