Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

Autoposting a form from one .pl file to another

I know how to do it in PHP/javascript



8:24 am on Mar 24, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

First of all, let's just be honest. I know NOTHING about perl. I did try to get my head round it but I am no perl - or other - programmer.

Basically I need to be able to post a form to a .pl file and on that pl file nothing happens other that autoposting it to another perl file.

In PHP I would do something like:


echo '<form method="post" action="other_perl_script.pl">;

foreach($_POST as $key => $value){
echo '<input type="hidden" name="'.&key.'" value="'.$value.'" />;

echo '</form>';


and have <body onload="form[0].submit()"> or something similar.

I did try using LWP::UserAgent; or the PHP:interpreter but with no luck. I just don't get perl.


11:36 pm on Mar 24, 2009 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

First, check your error logs.

Next, if that provides no love, verify the script works. Install perl on your local machine. From command line/DOS, type perl other_perl_script.pl (press enter.) You should see either script output or errors, and it will tell you approximately where to look.

If the script is fine, find out how and where it's reading and parsing the variables. This is done automatically in PHP, giving you $_POST, $_GET, or $_REQUEST. So somewhere will be something like

%data = &read_parse;

Where read_parse is the R/P routine, and now %data is the associative array (hash, in perl-ese) storing all the input values.

I've used %data as an example here, it can be any variable name. Some really lousy scripts do the read/parse inline, but it should be relatively easy to find.

Once you reach this point, paste this *immediately* after the %data variable has been populated:

print "content-type:text/html\n\n";
print "Test <br>\n";
foreach $k (keys %data) { print "key: $k value: $data{$k}<br>\n"; }
exit 0;

Subsitituting, of course, the hash name in your program for "data."

( The above is the semi-equivalent of var_dump($data) )

Try your script with this in place. If all you see is the word "test" you know a) the script is syntactically correct, but b) something in it is broken and it's not parsing out the form data.

If you see a list of the values you submitted, you know it's both syntactically correct and accepting data, but it's broken somewhere else. Move this chunk of code successively down through your script until you find out where it's breaking.


3:41 pm on Mar 25, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Thank you for your reply rocknbil, I'll give this a go.

Featured Threads

Hot Threads This Week

Hot Threads This Month