I found a piece of old code that I had written that goes to an FTP site and retrieves a file via LWP::Simple:

my $data = get('ftp://ftp.ncbi.nih.gov/refseq/LocusLink/LL_tmpl.gz') +; my $outfile = '>GO_TERMS.CSV'; if (!$data) { exit(); } open(OUT, '>LL_tmpl.gz'); binmode OUT; print OUT $data; close(OUT);

I thought: hey, that's silly because it loads the whole file into a variable. Why not rewrite it with Net::FTP? That should be shorter, clearer code, as well as much faster.

use Net::FTP; my $ftp = Net::FTP->new('ftp.ncbi.nih.gov', Debug=>0); $ftp->login('anonymous', 'anon@anon.com'); $ftp->cwd('/refseq/LocusLink/'); $ftp->type('binary'); $ftp->get('LL_tmpl.gz'); $ftp->quit();

The problem is, when I run the file downloaded via Net::FTP through a gzip -t it indicates a corrupt archive. When I get it from LWP::Simple, the archive seems valid. I've reproduced this on a couple of machines, but they are all behind the same router: can anyone validate this from other machines? Any ideas what's causing the FTP download to be invalid?

-Tats

Update: Warning! The downloaded file is rather large ~30 MB. (thanks for point it out b10m)


In reply to Unable to complete download with Net::FTP by Itatsumaki

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.