in reply to "Compile" Net::FTP upload script and use __DATA__ ?

Although I haven't tried it, the documentation says that you can use a filehandle with the put method, so after you login, you should be able to
$ftp->put(DATA, $remotefile);
You might also be able to use IO::Scalar to send a string as if it were a file handle. Whether either of these would work with a given compliler, shrug!

Replies are listed 'Best First'.
Re: Re: Net::FTP Question
by OverlordQ (Hermit) on May 16, 2003 at 21:26 UTC
    Using strict, it gives me:

    Bareword "DATA" not allowed while "strict subs" in use at ftp.pl line 12. Execution of ftp.pl aborted due to compilation errors.

    without strict, it gives me:

    Cannot open Local file DATA: No such file or directory at ftp.pl line 12

    Line 12 is: $ftp->put(DATA ,'index.html');

    Finally, skipping __DATA__ altogether and using IO::Scalar . . well nevermind . . that works wonderfully :)

    #!/usr/bin/perl use strict; use warnings; use IO::Scalar; use Net::FTP; my $ftp = Net::FTP->new("my.ftp.host", Debug => 0, Passive => 1); my $data = "<html><head><title>Foo</title></head><body>Bar</body></htm +l>"; my $SH = new IO::Scalar \$data; $ftp->login("username",'mypass'); $ftp->cwd("newpage"); $ftp->rename('file.html','file.old'); $ftp->put($SH ,'file.html');