Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Calling a perl script and passing parameters from html

by Jenda (Abbot)
on Nov 17, 2012 at 17:26 UTC ( #1004326=note: print w/ replies, xml ) Need Help??


in reply to Calling a perl script and passing parameters from html

If the script doesn't take too long to execute and you do not need to process it's results then a wrapper script like this should be enough to get you up and running:

use strict; use CGI; use CGI; my $q = new CGI; @ARGV = (); foreach ($q->param()) { $value = $q->param($_); $value =~ s/"/\\"/g; push @ARGV, "--" . $_ . '="' . $value . '"'; } do 'path/to/the/script.pl';

All it does is it moves the parameters from the querystring or post into the @ARGV array (array of script parameters) in the format required by the script and then executes the script without starting a new process.

As long as the script prints its results to STDOUT they should be sent to the client browser.

Jenda
Enoch was right!
Enjoy the last years of Rome.


Comment on Re: Calling a perl script and passing parameters from html
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1004326]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (16)
As of 2014-08-27 13:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (238 votes), past polls