如何将Perl脚本的输出包含到PHP页面中?

时间:2021-01-04 01:23:50

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.

我们被要求在新网站上支持一些相当旧的Perl表单,因为我们正在使用基于PHP的CMS,我们需要将Perl脚本包含到我们的新CMS中。

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

我已经尝试了一些shell_exec但是已经禁用了。有没有人有任何想法?

3 个解决方案

#1


Perl extension

There is a Perl extension available for PHP.

有一个可用于PHP的Perl扩展。

An article from the Zend developer zone details it here.

Zend开发人员专区的一篇文章详细介绍了它。

The extension allows you to:

该扩展程序允许您:

  • load and execute Perl files
  • 加载并执行Perl文件

  • evaluate Perl code
  • 评估Perl代码

  • access Perl variables
  • 访问Perl变量

  • call Perl functions
  • 调用Perl函数

  • instantiate Perl objects
  • 实例化Perl对象

  • access properties of Perl objects
  • 访问Perl对象的属性

  • call methods of Perl objects
  • 调用Perl对象的方法

You can obtain it from CVS using this command:

您可以使用以下命令从CVS获取它:

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

An example of running a Perl script is listed here:

此处列出了运行Perl脚本的示例:

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

#2


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.

如果您的Perl脚本正在创建包含客户端应该能够更改的表单的页面,那么您就不走运了。您可能会想出一些包含Perl脚本输出的PHP页面,但您永远无法将该页面上的任何更改反馈到Perl脚本中。

#3


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

那个php apache函数virtual()怎么样? http://php.net/manual/en/function.virtual.php我认为这个和mod_rewrite的组合是可行的

#1


Perl extension

There is a Perl extension available for PHP.

有一个可用于PHP的Perl扩展。

An article from the Zend developer zone details it here.

Zend开发人员专区的一篇文章详细介绍了它。

The extension allows you to:

该扩展程序允许您:

  • load and execute Perl files
  • 加载并执行Perl文件

  • evaluate Perl code
  • 评估Perl代码

  • access Perl variables
  • 访问Perl变量

  • call Perl functions
  • 调用Perl函数

  • instantiate Perl objects
  • 实例化Perl对象

  • access properties of Perl objects
  • 访问Perl对象的属性

  • call methods of Perl objects
  • 调用Perl对象的方法

You can obtain it from CVS using this command:

您可以使用以下命令从CVS获取它:

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

An example of running a Perl script is listed here:

此处列出了运行Perl脚本的示例:

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

#2


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.

如果您的Perl脚本正在创建包含客户端应该能够更改的表单的页面,那么您就不走运了。您可能会想出一些包含Perl脚本输出的PHP页面,但您永远无法将该页面上的任何更改反馈到Perl脚本中。

#3


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

那个php apache函数virtual()怎么样? http://php.net/manual/en/function.virtual.php我认为这个和mod_rewrite的组合是可行的