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

I have been trying to find a perl solution to POST data stored in scalars to a remote CGI script. I have been using a cut and paste PHP version for over a year - but I need something in perl.... I need to POST: $name, $email, $subject, $body to another cgi script for further use. a snippet I found does not seem to be working for me - most likely because I butchered it somewhere.... What is wrong here? Or is there a better solution?
use HTTP::Request::Common; $ua = LWP::UserAgent->new; $ua->request(POST 'http://remotescript.com',[ name => '$name', email => '$email', subject => '$subject', body => '$body']);
thanks in advance Monks! BTW - in case it matters - the contents of $body is a paragraph of 200 characters or less.

Replies are listed 'Best First'.
Re: POST to remote cgi from within local perl file?
by Zaxo (Archbishop) on May 31, 2002 at 03:16 UTC

    Your field values are not being interpolated from the variables. Try:

    name => $name,
    You don't need to quote those at all

    After Compline,
    Zaxo

Re: POST to remote cgi from within local perl file?
by DamnDirtyApe (Curate) on May 31, 2002 at 03:08 UTC
    I doubt this is the cleanest way to do what you want, but take a look at this post for an idea.
    _______________
    D a m n D i r t y A p e
    Home Node | Email