Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I include the output of a Perl script into a PHP page?

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?

like image 631
Tom Avatar asked Jun 25 '09 10:06

Tom


1 Answers

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! ";
?>
like image 168
Jon Winstanley Avatar answered Sep 19 '22 13:09

Jon Winstanley