in reply to Adding to Content on LWP Post

Once you call the post() method, your request is transmitted to the web server; it is too late to modify it. You need to store the form data in a structure that you can add to at runtime, and then use that structure in the post() call.

Try these array-based techniques to initialize and manipulate your form data:

my @form_data_pairs = ( 'Encounter1847760942' => $enc_id, 'SelectType1847760942' => 'StartOnSelect', 'Begin1847760942' => '01/02/2005', 'DaysBack1847760942' => '3', 'ProcedureSearchText1847760942' => '', 'EncounterOptionSelected' => 'false', ); # ... Code to handle dynamic options would go here ... my $cb = ($some_dynamic_flag) ? 1 : 0; push @form_data_pairs, ( 'checkbox' => $cb, 'something' => 'Something else', ); push @form_data_pairs, ('checkbox2' => 1) if $some_other_flag; my $response = $browser->post($url, \@form_data_pairs, @ns_headers);

If the form has no duplicate data elements, and the receiving application is not neurotic about parameter order, then hash-based techniques may be clearer and more flexible:

my %form_data = ( 'Encounter1847760942' => $enc_id, 'SelectType1847760942' => 'StartOnSelect', 'Begin1847760942' => '01/02/2005', 'DaysBack1847760942' => '3', 'ProcedureSearchText1847760942' => '', 'EncounterOptionSelected' => 'false', ); # ... Code to handle dynamic options would go here ... $form_data{'checkbox'} = ($some_dynamic_flag) ? 1 : 0; $form_data{'something'} = 'Something else'; $form_data{'checkbox2'} = 1 if $some_other_flag; my $response = $browser->post($url, [ %form_data ], @ns_headers);