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@/

In reply to Re: Using LWP's "post" to send n fields into a form? by fizbin
in thread Using LWP's "post" to send n fields into a form? by aboyd

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.