7

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?

brian d foy
  • 129,424
  • 31
  • 207
  • 592
Tom
  • 33,626
  • 31
  • 85
  • 109
  • Why? If you have some URLs covered by Perl scripts why do you need those under cms control? – innaM Jun 25 '09 at 11:29
  • Good question, we have some contact forms which submit into a horrible database app, on this same page we need the client to be able to change the content though the CMS. If there were any way I could not use Perl, I'd be all over it :) – Tom Jun 25 '09 at 12:15
  • 1
    That means that the forms themselves aren't generated by those Perl scripts? – innaM Jun 25 '09 at 13:00
  • Unfortunately yes, perl is making the forms, creating a unique ID for the target URL (even if the form is submitted or not) – Tom Jun 25 '09 at 13:24
  • Then I don't see how a php cms could possibly control the contents of the forms. You will have to dig into the Perl, rip out the html and get that under cms control. – innaM Jun 25 '09 at 13:40
  • See this similar question: [How can I use Perl libraries from PHP](http://stackoverflow.com/questions/1030736/how-can-i-use-perl-libraries-from-php) – senderle Jul 07 '12 at 13:59

3 Answers3

10

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! ";
?>
Alan Haggai Alavi
  • 72,802
  • 19
  • 102
  • 127
Jon Winstanley
  • 23,010
  • 22
  • 73
  • 116
  • Ah this looks like the perfect solution, except I'm not sure if we can load any extensions onto the hosting :( – Tom Jun 25 '09 at 11:06
0

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
  • 47,505
  • 4
  • 67
  • 87
-1

what about a php apache function virtual() ? http://php.net/manual/en/function.virtual.php I thing that combination of this and mod_rewrite is viable

NTPT
  • 1
  • To critique or request clarification from an author, please leave a comment below their post. Did you verify your proposed solution or do you only think that it might be working? – honk Sep 11 '14 at 18:57