[thelist] PHP/Perl: How do they talk?

Jeremy Ashcraft ashcraft at 13monkeys.com
Fri Jul 27 10:03:18 CDT 2001


use the popen function to open a pipe to the perl script and just pass your 
function to it as a parameter in single quotes.  All this does is have your 
PHP script open a perl script, pass it a parameter(the function) and listen 
for some output.....

Make your perl script look something like this:

#!/usr/bin/perl
 
$return = eval $ARGV[0];
 
print $return;
 
sub foo() {
     #do some stuff
    return true;
}

Then in your php script have something like this....
.....
$pipe = popen("path/to/yourscript.pl 'foo($user,$passwd)' ","r");
$return = fgets($pipe,1024);
pclose($pipe);
......

there you have your php and perl talking nice! 

HTH

jeremy

> And that's it. In effect, I'm interested in sending a function call from
> PHP to Perl, and returning a result from Perl to PHP. If anybody has any
> experience in getting these two brothers to talk to each other, then your
> assistance will be greatly appreciated.




More information about the thelist mailing list