Running perl module from PHP <--- HOWTO

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rustyambrose
Forum Newbie
Posts: 2
Joined: Sat Sep 13, 2003 2:28 pm
Location: Boise, ID

Running perl module from PHP <--- HOWTO

Post by rustyambrose »

I would like to run a perl module from a php page, using variables from the php page in the module, then needing a set variable from the module used back in the php. What is the best way to do this?
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

I don't know much of Perl but I belive you can do something like this:

cgi_module.pl:

Code: Select all

#!/usr/bin/perl

# treat arguments here...

# ...

# the print the significant data to PHP
print "This data was returned from the Perl script";
yourpage.php:

Code: Select all

<?php
$php_var = 'something';
$var_set_from_perl = `./cgi_module.pl $php_var`;// $php_var is the argument to the *executable* Perl script
echo 'The Perl script returned: ' . $var_set_from_perl;
?>
output:

Code: Select all

The Perl script returned: This data was returned from the Perl script
Take a look to the Execution Operators.

Hope it helps!

Regards,
Scorphus.
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

if you're not using cgi modules, make the perl script, and call it via the exec function, just set it to take variables via the command line that you feed it via the exec call
rustyambrose
Forum Newbie
Posts: 2
Joined: Sat Sep 13, 2003 2:28 pm
Location: Boise, ID

Post by rustyambrose »

Thanks scorphus, that's what I needed for the project I'm on. But I can see I might need to look into m3rajk's idea to see if the variables will be sent over from the perl, vs setting one variable equal to everyting.
Post Reply