Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Calling perl script from PHP
February 23, 2007, 5:25 am
rate this thread
I need to develop a web based application which uses php for the front
end and statistical manipulations in perl - my question is - how do i
call a perl script from php - i guess the answer is gonna be exec. I
cant seem to understand how can i pass variables from the PHP script
to the Perl script and vice versa using exec? Is there a better way to
go about it?
Re: Calling perl script from PHP
You could store all your variables in one big array, serialize() the
array, and then pass it to Perl as STDIN. In Perl, you can then use Scott
Hurring's implementation of unserialize() to retrieve the data.
Passing data back, again, in Perl bundle the data up into a Perl hash,
serialize() it using Hurring's module, and then print it to STDOUT. PHP
reads the STDOUT and unserializes the data.
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux
* = I'm getting there!