I'm betting that you've got a permission problem, since you're probably not running the test script as the same user as the CGI script. This is one of the reasons you should check the return value of unlink(), open() etc and give a meaningful error message:
unlink( $fileName ) or die "Can't unlink $fileName: $!";