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?
prakashk021799Connect With a Mentor Commented:
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.
gnagabandiAuthor Commented:
Edited text of question.
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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:
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.
All Courses

From novice to tech pro — start learning today.