pg has asked for the wisdom of the Perl Monks concerning the following question:
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"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: question about Net::FTP + in memory file handler
by crenz (Priest) on Apr 14, 2003 at 20:34 UTC | |
by pg (Canon) on Apr 15, 2003 at 02:11 UTC | |
|
Re: question about Net::FTP + in memory file handler
by runrig (Abbot) on Apr 14, 2003 at 20:39 UTC |