Downes's referrers scrip

I’ve been having terrible trouble getting the referrer script at installed locally. It’s possible to run it using his database, but that can slow loading of a page. With Downs’s help, I got the file names and permissions not just right but confirmed to be right (755s)-- yet the script seems unable to write to my data directory. It opens a file of zero bytes, but puts no conent in it.

Has anyone been able to get this to run?

PS. the two lines that need configuring in the .cgi script now read:

$datamain = “/home/{username}/{domain name}/cgi-bin/data”;
$datadir = $datamain . “/”; #Directory of data file

where {username} is my user name and {domain name} is my domain name.
the other directories exist and have 755 permissions. The script lived in …/cgi-bin