Using Perl from PHP

I know, mixing and matching is messy. Here’s my problem though – I’m currently working on a project that requires both standalone code (Perl/Bioperl) and a web interface. Now, I could just convert my Perl to CGI for the web – but I want to work within a CMS framework that uses PHP. I don’t especially want to rewrite the Perl as PHP and in some cases I can’t, because the Bioperl functions are not available in PHP. Leaving me no choice but to access my Perl from PHP. How?

Enter the PHP Perl extension. It requires PHP 5.0.0 or higher. On my Ubuntu system, I installed libapache2-mod-php5, php5-cgi and some other useful php5 modules (php5-gd, php5-xsl, php5-mysql). You also need libperl-dev and php5-dev, which supplies the commands phpize and php-config. Download the extension from this link, unpack and follow the instructions in the README. Enable “extension=perl.so” in /etc/php5/apache2/php.ini, restart Apache and you’re set. You can now access Perl code and variables from within PHP5.