As an exercise, I try to follow these instructions on Using Perl Code from PHP (devzone.zend.com).

The environment is as follows:

$ perl -v | grep built This is perl, v5.8.5 built for i386-linux-thread-multi $ php -v | grep built PHP 5.1.6 (cli) (built: Jun 17 2007 11:44:56)
I downloaded this package and compiled as follows:
export PHP_PREFIX="/usr" export PERL_PREFIX="/usr" $PHP_PREFIX/bin/phpize ./configure --with-perl=$PERL_PREFIX --with-php-config=$PHP_PREFIX/bin +/php-config make sudo make install
Then I did a added extension=perl.so to /etc/php.ini:
$ grep -i extension /etc/php.ini | grep -v '^;' extension_dir = "/usr/lib/php/modules" extension=perl.so
The shared perl library seems to be in place:
$ ll /usr/lib/php/modules/ | grep perl -rwxr-xr-x 1 root root 150234 May 6 08:56 perl.so
But when I try to run this simple sample, I get the error below:
$ cat perl.php <?php $perl = Perl::getInstance(); ?> $ php perl.php PHP Fatal error: Call to undefined method Perl::getinstance() in perl.php on line 2
Has anyone succeeded interfacing perl from php using the above approach?

(Note that I also tried PHP::Interpreter without success. make test reports PHP/Interpreter/Interpreter.so: undefined symbol: _zval_ptr_dtor).

Update (RESOLVED): I made a mistake when copying sample code, as kindly noted by moritz:

$ cat call.perl.from.php <?php #$perl = Perl::getInstance(); $perl = new Perl(); $perl->eval(" print \"Executing Perl code in PHP\n\" "); ?> $ php call.perl.from.php Executing Perl code in PHP
--
No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]

In reply to Using Perl Code from PHP by andreas1234567

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.