#!/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;