I got a problem here. See comment in the code for detail. Is it with my program? Is it with in memory file handler? Is it with Net::FTP? Anyone noticed this before?

I thought in memory file handlers can be used almost without you know.

Thanks in advance.
use Net::FTP; use strict; #This works. It opens a in memory file first, passing it to a sub, and + do something. { my $in_mem; print "First try something else\n"; open(AFILE, ">", \$in_mem); write_okay_okay(*AFILE); close(AFILE); print $in_mem, "\n"; } #This does not work. It opens a in memory file, passing it to Net::FTP +->get(). #However got error msg complained bad file descriptor { print "Now try FTP with in mem\n"; my $ftp = new Net::FTP("Kyanite", Debug => 1); $ftp->login("user name", "password"); my $in_mem; open(BFILE, ">", \$in_mem) || die "failed"; print BFILE "okayokay"; $ftp->get("MComSubChng.txt", \*BFILE); $ftp->quit(); close(BFILE); print $in_mem, "\n"; } #This works fine. It opens a normal file, and pass the handler to Net: +:FTP->get(). #I checked, and the local file was created { print "Now try FTP norm\n"; my $ftp = new Net::FTP("Kyanite", Debug => 1); $ftp->login("user name", "password"); open(BFILE, ">", "bfile") || die "failed"; $ftp->get("MComSubChng.txt", \*BFILE); $ftp->quit(); close(BFILE); } sub write_okay_okay { my $file = shift; print $file "okay okay"; }

In reply to question about Net::FTP + in memory file handler by pg

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.