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

forms, include, perl, php

Solution

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! ";
?>

Problem

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?

Original source

Related problems