I have a perl script that performs operations on a large amount of data and builds a table. I want to call upon this script from PHP. I am passing tabular data which contains strings, quotes, and all kinds of nastyness so a simple
passthru('./path/to/pl $var1 $var2');
won’t do. I was thinking of JSON encoding the data then base64 encoding the JSON and passing like:
passthru('./path/to/pl "$base64edJSON"');
Is this a proper way or is there a better way? The perl script must return the completed table back to the PHP script through a return, stdout, or some other means.
You can call the perl script using proc_open. Then you can feed the input to it through stdin and get the output/errors from stdout. The Perl script will run as a pipe.
This gets around any messiness with temporary files.