Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl interpreter for PHP

Some of the functions I am planning for a new site of mine are already available as free Perl modules. Hence I am looking at the possibility of using them, rather than coding them again in PHP. I was planning to use exec or system function to call the perl script, which will be slow. But I came across a pecl extension which allows PHP to interpret perl code.

Will this affect the performance of my other php pages, which are not using the perl script? I understand that the extra module will increase my memory usage, but other than that, will there be any issues?

like image 799
Joyce Babu Avatar asked Mar 15 '26 06:03

Joyce Babu


1 Answers

It looks like all it is doing is embedding perl inside the PHP process. You should see a memory increase of a few megabytes plus any data you create in Perl. It should not slow down any code. It is just another library sitting in memory waiting for you to call it. There are two benefits of this solution: you don't have to waste time spawning another process and you don't have to parse the return values from text being printed.

Another solution is to write a Perl daemon and talk to it over a domain socket, pipe, or some other method of IPC.

You might also be interested in the Perl documentation covering embedding perl.

like image 63
Chas. Owens Avatar answered Mar 17 '26 20:03

Chas. Owens