I am interested in knowing the ways we can call/run Perl scripts in PHP.
Asked
Active
Viewed 1.6k times
10
-
Related: [How can I call Perl from my PHP page on apache?](http://stackoverflow.com/q/827302), [Calling Java (or python or perl) from a PHP script](http://stackoverflow.com/q/299913), [How to run perl script with a few arguments from php](http://stackoverflow.com/q/2908274), [How can I include the output of a Perl script into a PHP page?](http://stackoverflow.com/q/1043230) – daxim Sep 17 '10 at 13:17
-
possible duplicate of [How can I include the output of a Perl script into a PHP page?](http://stackoverflow.com/questions/1043230/how-can-i-include-the-output-of-a-perl-script-into-a-php-page) – Ether Sep 17 '10 at 14:52
-
Also http://stackoverflow.com/questions/1030736/how-can-i-use-perl-libraries-from-php – Alexandr Ciornii Sep 18 '10 at 20:19
4 Answers
15
You can use a simple Php Perl extension within the Php code. This will allow you to execute code and Perl variables,functions and instantiate objects.
$perl = new Perl();
$perl->require("test1.pl");
-
1+1 Nice answer. I have made small formatting changes to your question to use the code highlighting features of SO. – Andrie May 04 '11 at 08:32
-
-
1
2
Just like any other executable.
But avoid it, it's very inefficient. What do you want to achieve by doing it?

reinierpost
- 8,425
- 1
- 38
- 70
-
I was trying to use perl for accessing system resources like webcam, then call that script in my existing php application. – awake416 Sep 17 '10 at 09:00
-
@awake416 Whose webcam? If there is a webcam attached to the server and you can access it using Perl, then it should not be difficult to access it in PHP as well. – Sinan Ünür Sep 17 '10 at 11:48
-
-
@awake416 I don't know. Just like I do not know how you are accessing it in Perl. All I am saying is, if you can do it in one, you should be able to do it in the other language as well. – Sinan Ünür Sep 17 '10 at 12:53
-
1Conversely, you can write your whole website in Perl using mod_perl to avoid the overhead of invoking the Perl interpreter on each call. – reinierpost Sep 17 '10 at 22:22
-
PS: People tell me there are better alternatives to mod_perl to do that nowadays. – reinierpost May 04 '11 at 09:41