PHP perl extension is available to allow the usage of perl code in PHP.
The perl extension is used to 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 objects.
PHP's perl extension is available from the PECL web site at http://pecl.php.net/package/perl. The latest development version can be obtained with the following CVS command:
If you have a full perl installation, the extension will work with it. If you don't have perl on board, you can still communicate with the perl interpreter through PHP by putting a copy of perl58.so or perl58.dll somewhere PHP can find it (in the PHP directory or in your system path).
To access the perl interpreter from PHP, you must first create an instance of the Perl class.
$perl = new Perl();
External perl files can be loaded using the Perl::require() method. An example is:
<?php
print "Hello from PHP! ";
$perl = new Perl();
$perl->require("kiranhota.pl");
print "Bye! ";
?>
The system() function will start the interpreter each time it's called, whereas $perl->eval() uses the embedded interpreter in the same address space and doesn't need to create a new process. An example is:
<?php
print "Hello from PHP! ";
$perl = new Perl();
$perl->eval('print "Hello from perl! "');
print "Bye! ";
?>
- Kiran's blog
- 693 reads













Post new comment