Here are a couple of scripts I use when playing with POSTs. They are from an ecommerce program that I used to learn Perl. I hope they help you understand what is being done in an actual POST.
#!/usr/bin/perl use warnings; #use this to test cc transaction, it simulates the output of perlshop use warnings; use HTTP::Request::Common qw(POST); use LWP::UserAgent; $grand_total= '109.34'; $order_id= '999999999'; $street1= '9 9th Street'; $country= 'US'; $email= 'z9@z9.com'; $first= 'zjoe'; $last= 'zmon'; $card_no= '4111 1111 1111 1111'; $exp_mon= '09'; $exp_yr= '2004'; $zip= '48127'; $ua = LWP::UserAgent->new(); $req = POST 'http://zentara.zentara.net/~zentara/cgi-bin/store/respgen +.pl', ['IOC_merchant_id' => '1983645028456zz', 'IOC_order_total_amount' => "$grand_total", 'IOC_merchant_shopper_id' => 'susehost', 'IOC_merchant_order_id' => "$order_id", 'ecom_billto_postal_street_line1' => "$street1", 'ecom_billto_postal_postalcode' => "$zip", 'ecom_billto_postal_countrycode' => "$country", 'ecom_billto_online_email' => "$email", 'ecom_payment_card_name' => "$first $last", 'ecom_payment_card_number' => "$card_no", 'ecom_payment_card_expdate_month' => "$exp_mon", 'ecom_payment_card_expdate_year' => "$exp_yr", 'url' => 'http://zentara.zentara.net/~zentara/cgi-bin/shop/boacc.pl' +, ]; $content = $ua->request($req)->as_string; print $content;
and if you want to setup a relay, you can manually construct the POST url string.
#!/usr/bin/perl use warnings; use CGI; use LWP::UserAgent; my $test= 'TRUE'; #my test= 'FALSE'; my $relay; my $cgi = new CGI; my %input= $cgi->Vars(); open (TEST,"+>zrelayvars"); foreach $name (keys %input){ $value = $input{$name}; print TEST "$name=$value\n"; $relay .= "$name=$value&"; } $relay .= "Ecom_transaction_complete=$test&"; $relay .= "IOC_response_code=0&"; close TEST; my $ua = LWP::UserAgent->new(); my $req = HTTP::Request->new (POST => 'https://zentara.zentara.net/~ze +ntara/cgi-bin/shop/boacc.pl'); $req->content_type('application/x-www-form-urlencoded'); $req->content("$relay"); my $res = $ua->request($req); print $res->as_string;

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

In reply to Re: LWP::UserAgent and Array of hashes by zentara
in thread LWP::UserAgent and Array of hashes by DreamT

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.