in reply to Easy way to FTP get() only first few bytes?

Hmmm, the following reads the first 200 bytes for a given file. Uses the fact that the retr method returns a file handle on which you can call read() with a specific size.

#!/usr/bin/perl use strict; use Net::FTP; my $ftp = Net::FTP->new("ftp.nai.com") or die "cannot connect: $@\n"; $ftp->login("anonymous",'anon@') or die "Cannot login: ", $ftp->messag +e; #print $ftp->ls or die "ls failed: ", $ftp->message; my $dataconn = $ftp->retr('legal.txt'); my $buffer; my $bytes_read = $dataconn->read($buffer, 200); print $buffer;