View Single Post
Old Feb 13th, 2008, 2:21 PM   #1
Johnmcter
Newbie
 
Join Date: Feb 2008
Posts: 1
Rep Power: 0 Johnmcter is on a distinguished road
LWP form Data array issues

ok, I hate to be some noob who shows up asking for help on their first post, but here goes it. I'm using LWP to post some form data, and have everything working fine, I'm running into issues with how this data is handled when coming from a seperate file though. The seperate data is listed as

    'beta' => 'info',
    'charly' => 'here',
    'alpha' => 'something',

Everything works great if I pass it within the script to the array as such

@form_data = (
    'beta' => 'info',
    'charly' => 'here',
    'alpha' => 'something',
);

But when grabbing as outlined below I get these semi colons, and it isn't processing them in my http headers, things also appear to be alphabetical

Content-Type: application/x-www-form-urlencoded

    'alpha' => 'something',
:     'beta' => 'info', 
    'charly' => 'here',

a sample script is below
#!/usr/bin/perl -w
use LWP::UserAgent;

my $browser = LWP::UserAgent->new( );
my @custom_headers = (
  'User-Agent' => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)',
  'Accept-Language' => 'en',
  'Accept' =>
   "text/html, text/plain, text/css, text/sgml, */*",
);

 open (FORMFILE, "$dir/$formfile");
 @form_data = <FORMFILE>; 
 close(FORMFILE);

 open (INFO, "file.txt");
 @temparray = <INFO>;
 close(INFO);

 $post_url = "http://www.somesite.com/something";
 $post_html = "post.html";


 my $post_response = $browser->post($post_url, @form_data, @custom_headers, ':content_file' => $post_html,);

Last edited by Johnmcter; Feb 13th, 2008 at 2:22 PM. Reason: clarrity
Johnmcter is offline   Reply With Quote