I'm developing a module that takes user input, creates an input file and then makes an external call to a Perl script. The Perl script parses the input file and writes an appropriate binary file and then the module serves up the binary file. It all works great unless the output binary file it tries to create is larger than approx. 50MB. Then it outputs the first 50 bytes only and returns an error. If the binary file it creates is 45MB it works fine.

I thought that the problem might be a PHP problem so I tried many alternative functions for calling the Perl script from within PHP. I looked at the PHP.ini file to see if there was a configuration problem (there isn't). The Perl script works great executing it from the command line and it works great if I call it from within a stand-alone PHP script. It only has the 50MB problem when it's running inside my Drupal module.

Any thoughts?