marrocco has asked for the wisdom of the Perl Monks concerning the following question:

How can I treat the contents of a variable as a file for upload (without resorting to the use of tempfiles)?
Use an "undef" as $file value if you want to specify the content directly.
makes it sound feasible, but I'm not clear on how to specify the content and have been unable to find any examples. Suppose $x contains the data I wish to treat as a file. Where and how to I code it?
my $ua = LWP::UserAgent->new(); my $req = POST $url, Content_Type => 'form-data', Content => [blah => $something, file => [undef,'foo.txt'] ];
Thanks...

Replies are listed 'Best First'.
Re: Uploading a variable as a file usingHTTP::Request::Common
by marrocco (Initiate) on Dec 19, 2001 at 02:28 UTC
    Found the answer at http://groups.google.com/groups?q=HTTP::Request::Common+upload&hl=en&rnum=1&selm=m3snel5r7a.fsf%40ActiveState.com
    my $ua = LWP::UserAgent->new(); my $req = POST $url, Content_Type => 'form-data', Content => [blah => $something, file => [undef, 'foo.txt', content_type => 'text/plain', content => $x ] ];