use IO::File; use Fcntl qw(:seek); my $fh = IO::File->new_tmpfile or die "Couldn't create tempfile: $!\n"; print $fh <<"END"; The contents of the file. END seek $fh, 0, SEEK_SET or die "Couldn't rewind temp file: $!\n"; $ftp->put($fh, "ftptest"); close $fh; # tempfile should be gone now.