如何使用 PHP 中的 Perl 库? [英] How can I use Perl libraries from PHP?

查看:18
本文介绍了如何使用 PHP 中的 Perl 库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 PHP 应用程序中的 Perl 库.我听说这是可能的.

I want to use Perl libraries from a PHP application. I have heard that it is possible.

我已经考虑过用 PHP 重写库的可能性,但我认为这不是一个好主意,因为这很困难.

I have considered the possibility of re-writing the libraries in PHP, but I do not think that is a good idea because it is difficult.

推荐答案

您也可以使用 PHP::Interpreter 来自 CPAN.这允许您在 Perl 中嵌入 PHP 解释器,并且对您更有用的是,在 PHP 中创建 Perl 对象:

You could also use PHP::Interpreter from CPAN. This allows you to embed a PHP interpreter in Perl and also, more usefully for you, to create a Perl object in PHP:

<?php
    $perl = Perl::getInstance();
    $fh = $perl->new("IO::File", "<$file");
    while($fh->getline()) {
      # ...
    }
  ?>

这篇关于如何使用 PHP 中的 Perl 库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆