it runs the script OK - the calls happen at the right time, but the perl script reads lines from stdin and writes responses to stdout. What gets written to stdin is empty under apache.

If it were perms, I think the script would fail to run at all.