I am trying to set up a block to call a Perl script. I am using the technique described here:
http://devzone.zend.com/node/view/id/1712
The PHP perl extension was implemented to allow the usage of perl code from within PHP. It is a wrapper that embeds the perl interpreter and converts data from PHP to perl and back. At the time of writing it only provides a one-way interface from PHP to perl, but in the future it could be extended to implement a full two-way interface. The perl extension allows the programmer to do the following from a PHP script:
* 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 objectsAll these features are accessible through a single API class called Perl.
I tried creating a block with the code from the example in this page:
<?php
print "Hello from PHP! ";
$perl = new Perl();
$perl->eval('print "Hello from perl! "');
print "Bye! ";
?>but, now I'm getting this message:
Hello from PHP!
Fatal error: Class 'Perl' not found in /home/schulerl/public_html/drupal/includes/common.inc(1537) : eval()'d code on line 4so.. where do I put the php Perl extension code within the drupal system?
I'm sure I'm not the only person to try to execute a perl script from drupal, but I can't find anything written up on how to do it.
Thank you for any information you can give me.
Comments
It sounds like you don't
It sounds like you don't have the PHP Perl extension installed on your server - this is an issue at the PHP level, not something Drupal can do much about.
Unless you have root access to your machine, you'll need to talk to your web hosts.
the error message
indicates that it is looking in the drupal includes folder.. but you are saying that it looks for it on the server first? then, when it can't find it, it looks for it in Drupal.. then issues the error message?
and, I will ask my host to install this.
Lynne
not quite
That line in common.inc is where Drupal fails to run the code in your block, because the Perl class isn't found. It doesn't 'look for' the class, if you call it, PHP just expects it to be available.
what ended up working
just wanted to post what I did that worked, for anyone else trying to do something similar.
I ended up using the code that I use to generate the random image from gallery2, and modified the call to call my php script.
here is what I ended up using, and what works:
now, I don't have much experience with PHP, so perhaps this could have been done easier.. especially since I'm calling the script from my own site, not another site. but.. hey, this works.
however, if someone has an easier way to execute a perl script and display the results withing a page or block, please feel free to share it.
:)
Lynne
what ended up working
Chances are you forgot to restart Apache.