>  works fine using php on the command line, but not via a browser. 

Have you checked your web-server's error log?

That's how I debug perl-driven web pages.