views:

308

answers:

3

We've been asked to support some rather old Perl forms on a new site, as we're using a PHP based CMS we need to include the Perl scripts into our new CMS.

I've tried a bit of shell_exec but that's disabled. Has anyone got any ideas?

+6  A: 

Perl extension

There is a Perl extension available for PHP.

An article from the Zend developer zone details it here.

The extension allows you to:

  • load and execute Perl files
  • evaluate Perl code
  • access Perl variables
  • call Perl functions
  • instantiate Perl objects
  • access properties of Perl objects
  • call methods of Perl objects

You can obtain it from CVS using this command:

$ cvs -d :pserver:cvs.php.net:/repository co pecl/perl

An example of running a Perl script is listed here:

Example 1 (test1.pl)

print "Hello from Perl! "

Example 1 (test1.php)

<?php
print "Hello from PHP! ";
$perl = new Perl();
$perl->require("test1.pl");
print "Bye! ";
?>
Jon Winstanley
Ah this looks like the perfect solution, except I'm not sure if we can load any extensions onto the hosting :(
Tom
+1  A: 

See similar question: How can I use Perl libraries from PHP?

Alexandr Ciornii
A: 

If you Perl script is creating the page with the forms that you client is supposed to be able to change, then you are out of luck. You might be able to come up with some PHP page that contains the output of the Perl script, but you'll never be able to feed any changes on that page back into the Perl script.

innaM