faqts : Computers : Programming : Languages : PHP : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

20 of 38 people (53%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

How do I pass parameters generated by PHP script to a Perl script?

Feb 14th, 2001 11:40
Per M Knutsen, James Reid,


Well, assuming you don't want to call the Perl script from PHP, but 
rather just link to Perl script, then as usual:
http://domain/path/script.pl?var1=num1&var2=num2&var3=num3
In your Perl code, use CGI.pm for parsing the query string:
#!/usr.bin/perl
use CGI qw(:standard);
$a = param ("var1"); # $a is now "num1"
$b = param ("var2"); # $b is now "num2"
$c = param ("var3"); # $c is now "num3"
If the variables are generated by a form then:
<FORM ACTION=script.pl METHOD=post>
  <INPUT TYPE=hidden NAME=num1 VALUE=$myvar1>
  <INPUT TYPE=hidden NAME=num2 VALUE=$myvar2>
  <INPUT TYPE=hidden NAME=num3 VALUE=$myvar3>
      other form elements go here...
  <INPUT TYPE=submit>
</FORM>
where $myvar1 etc are variables in your PHP script.