10

I am interested in knowing the ways we can call/run Perl scripts in PHP.

brian d foy
  • 129,424
  • 31
  • 207
  • 592
awake416
  • 301
  • 1
  • 3
  • 12
  • 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 Answers4

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");
Andrie
  • 176,377
  • 47
  • 447
  • 496
Hossome
  • 159
  • 1
  • 4
5

You can make use of

codaddict
  • 445,704
  • 82
  • 492
  • 529
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
  • @Sinan how can i access in php – awake416 Sep 17 '10 at 12:44
  • @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
  • 1
    Conversely, 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
1

Use something like

system("/your/kewl/script.pl");
Conner
  • 30,144
  • 8
  • 52
  • 73
tex
  • 2,051
  • 1
  • 23
  • 27