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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|