You are close, but you have to print the data into the filehandle first. The following would work, were it not for the fact Net::FTP hangs while putting (not like there is alot of choice).
### i know this does not work, i am showing the idea my $ftp = Net::FTP->new($server,$user,$pass); $ftp->cwd("/some/dir"); pipe(R,W); $ftp->put(\*R,'filename'); print W "data here\n"; $ftp->quit;
So, the other way is to fork a process and have it do the writting into W. Like the following (untested code ahead) :
pipe(READ,WRITE); $pid = fork(); if ($pid == 0) { ## child (read) close(WRITE); $ftp->cwd("/some/dir"); $ftp->put(\*READ,'filename'); $ftp->quit; } else { ## parent (write) close(READ); ## ... do some cool processing for $data print WRITE $data; close(WRITE); }
... i have not tested this, but it should work. I guess if you are on unix you could also use mknod to make a named pipe, and use that.
can't sleep clowns will eat me
-- MZSanford

In reply to Re: ftp put without a local file by MZSanford
in thread ftp put without a local file by fsn

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.