How to cause form submit action in perl.

My perl program takes one HTML file which contains a form as input. Then it changes the ACTION by using parse module to point another perl/CGI program. Now how can I cause submit action dynamically in perl to invoke the program? The program has to take all the form parameters as input. If LWP module is the solution, how I have to use LWP? Any suggestion will be greatly appreciated.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gnagabandiAuthor Commented:
Edited text of question.
Here's an example that I wrote up for someone a week ago for a very similar question regarding a CGI script invoking another CGI script.  It demonstrates the use of a POST.  

The html form sends it output to, receives it and reposts it to the Experts-Exchange search engine.  The resulting page is altered slightly :-) and displayed.

Here's the html page which references the first cgi
Search EE:<BR>
<form action="" method="post">
<input type=hidden name=ta value="57">
<input type=text size=30 name=search value=""><BR>
<input type=radio name=everything value="" checked>&nbsp;&nbsp;Search CGI Topic Area<br>
<input type=radio name=everything value=1>&nbsp;&nbsp;Search Everything<BR>
<input type="submit">

  use HTTP::Request::Common qw(POST);
  use LWP::UserAgent;
  use CGI;

  $myCGI = new CGI;
  $ua = new LWP::UserAgent;

# Create a hash of all the parameters
  foreach ($myCGI->param) { $myparams{$_} = $myCGI->param($_); }

  my $req = POST '', [ %myparams ];
  my $page = $ua->request($req)->as_string;

  $page =~ s#</head>#<base href=""></head>#i;

  $page =~ s/Experts Exchange/Clockwatcher's/g;

  print $page;


If my server happens to be up, you can check it out at:
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

You can generate a lot type of forms. What actually is the type of the form that you want for there's always different type of handling between data-recording form, mailing form, info form, search-engine type form etc etc.

- MasterGaurav
gnagabandiAuthor Commented:
I want to describe my problem with more details. My perl program takes one html file as input(right now CGI doesn't come in to picture). The html file contains one form with some input fields as empty. Then by using other perl subroutine I filled some form parameters and also changed the action to invoke other CGI program. In the next step, I have to execute/invoke the CGI program in this same perl script(as if we submit online forms), which has to take all the form parameters as input.

 My form is just info type. All the above tasks should be done at a single stretch. How to invoke the program to cause submit action of the html form.

 I have some restriction with using LWP::UserAgent, as I have to prepare the entire form parameter list(because I am reading directly from HTML file). If I had submit the HTML form by online, I would have all the parameter list available in array form.

 Is there any way to cause dynamic submit action in perl. I will be greatful to you for any solution.
Look at the recent column by Randal Schwartz ("Automatically testing a form"), which appeared in the November issue of "WebTechniques". It is available at <>

The source listing is at <>

He presents a program to parse an HTML page containing a form and to generate another perl program to POST to that form. It may not be readily usable "out-of-the-box" for you. But you could adapt it to your needs.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.