Are you sick and tired of writing to a file with Net::FTP? Have you thought "gee, it would be nice if graham had made it possible for me to write to a scalar?"
Well, monks, I have. And tonight I decided it was time to do something about it.
So, I present Net::FTP::Scalar.
Here is the sample code, and the module is available on envy.posixnap.net.
#!/usr/bin/perl
use warnings;
use strict;
use Net::FTP::Scalar;
$Net::FTP::Scalar::SCALAR_MODE = 1;
my $OUT_FILE;
my $ftp = Net::FTP::Scalar -> new("ftp.isi.edu", Debug => 0);
$ftp -> login("anonymous", "foo@");
$ftp -> cwd("/in-notes");
if (not $ftp -> get("rfc1001.txt")) {
$ftp -> quit;
die "could not ftp ...\n";
}
else {
$OUT_FILE = $Net::FTP::Scalar::OUT_FILE;
}
print $OUT_FILE;
exit 0;
--
Laziness, Impatience, Hubris, and Generosity.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.