Ian Duplisse <[EMAIL PROTECTED]> writes:

> I am uploading files via HTTP::Request::Common::POST, but would like 
> to modify the data that is actually uploaded to the webserver "on the fly", 
> such as with a search and replace.  How can that be done, short of making a 
> copy of my original file that has the desired changes?

Something like this should work:

#!/usr/bin/perl 

use HTTP::Request::Common qw(POST);

my $file = `cat stuff.txt`;  # slurp a file
$file =~ s/foo/bar/g;        # modify it

my $req = POST('http://foo.com/',
               Content_Type => 'form-data',
               Content => [ foo => $bar,
                            file => [ undef, "stuff.txt",
                                      Content_type => "text/plain",
                                      Content => $file,
                                    ],
                          ],
              );

print $req->as_string;

use LWP::UserAgent;
$ua = LWP::UserAgent->new;
my $res = $ua->request($req);
__END__


Regards,
Gisle

Reply via email to