I have a simple script which uses Net::FTP to connect to NAI's site and download various updates. The script works but I have a question about a warning/error that intermittently shows up. The message is:
Unable to close datastream at script.pl line 92
Line 92 is:
$ftpmsg = $ftp->get($listing{$x}[$y][0],"/$path1/$path2/$x/$listing{$x +}[$y][0]");
The only problem caused by this is emotional distress because I don’t have any idea what I might be doing wrong to cause this warning. Here is a small snippet of the code:
… $ftp = Net::FTP->new("ftp.nai.com", Debug => 0) or die "Cannot connect + to ftp.nai.com: $@\n"; $ftp->login("anonymous","user\@domain.com") or die "Cannot login to ft +p.nai.com: " . $ftp->message . "\n"; $ftp->binary() or die "Cannot change to binary data format: ". $ftp->m +essage() . "\n"; … $counter = 0; do { $counter++; $ftpmsg = $ftp->get($listing{$x}[$y][0],"/$path1/$path2/$x +/$listing{$x}[$y][0]"); } until ($ftpmsg eq "/$path1/$path2/$x/$listing{$x}[$y][0]" || + $counter >= 10); …
Any information would be greatly appreciated.

Thanks,
Chris

Update:
I looked at the code for Net::FTP and found this at the end of the get subroutine:
unless ($data->close()) # implied $ftp->response { carp "Unable to close datastream"; return undef; }
Since it uses carp instead of croak, I'm pretty sure that this is a warning and not an error. However, I'm still not quite sure what this means. It appears to me, a relative novice, that the file was downloaded but since the connection could not be closed, the routine returns undef which tells me the download failed even though the file is probably intact. Is there a way to fix this or do I just have to learn to live with it?

In reply to Unable to close datastream by ChrisR

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.