Hello, I would like to execute perl script in an HTML page, using PHP code. I need to do this as both PHP and HTML cannot be parsed simultaneously using SSI codes in .htaccess files. I am using the code for parsing PHP tags in my HTML pages. Now, I need to run a perl script also. How to do ? :disappoin
Hi, You can call/execute PERL script inside the PHP tags. You need to download the PERL extension for PHP and add to PHP. Then you can do like this: Method 1: Call a PERL script file. Code: <?php $perlobj = new Perl(); $perlobj->require("sample.pl"); // sample.pl is the PERL script file $contents = ob_get_contents(); ob_end_clean(); print "Output: $contents"; ?> Method 2: Execute PERL script inside PHP. Code: <?php $perobj = new Perl(); $perlobj->eval('print "Hello, this is a PERL script."'); ?>
In the second method, the contents inside the eval() function should be enclosed within single quotes, implying that eval() takes only one parameter as string and that is the PERL script itself.
Hi, Thanks for your solution. But, these methods won't work for me. I am working in a shared server platform and the package required for creating the perl object through "new Perl()" is not installed and not possible for installation also. I need some htaccess way if possible. Also, I would like to know if there is some method by which PHP will run from HTML pages and also SSI will run to execute perl scripts. Might be I am asking too much in one go
Hi codestorm, You can use SSI in your HTML file to run PHP and PERL scripts. To run PHP: Code: <!--#include file='file_name.php' --> To run PERL: Code: <!--#exec cmd='perl sample.pl' -->