in reply to Using LWP's "post" to send n fields into a form?

Assuming that the code you've given so far is correct, then this should do the iteration for you:
$webpage = $browser->post($form_url, [ username => $username, (map {widget => $widget{$_}} (keys %widget)), created => '1126175051' ],Content_Type => 'form-data'));
Although I find it a bit odd that widget is a hash. If perhaps widget is really an array, then the code you need is this:
$webpage = $browser->post($form_url, [ username => $username, (map {widget => $_} @widget), created => '1126175051' ],Content_Type => 'form-data'));
To debug this, I would strongly recommend doing something like this in your code:
my $lwparg = [ username => $username, (map {widget => $widget{$_}} (keys %widget)), created => '1126175051' ]; use Data::Dumper; print Data::Dumper->Dump([$lwparg],['lwparg']); $webpage = $browser->post($form_url, $lwparg, Content_Type => 'form-da +ta'));
Then you can test out variants of lwparg until you get one that's passing the right stuff.
--
@/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/

Replies are listed 'Best First'.
Re^2: Using LWP's "post" to send n fields into a form?
by aboyd (Sexton) on Sep 10, 2005 at 13:19 UTC
    Thank you so much! You were right -- I was using an array, not a hash. And your code worked perfectly. -Tony