in reply to code problem

The error itself should be reported in the server error log. That should be your first place to check. The code itself is syntactically correct, however, I'd error check your 'open' call. I don't know, but that extra new line might be causing you a problem. You are telling the browser to expect a binary stream and the first thing it gets is a new line. Like I said, that may, or may not be your problem. If not, then there are several ways you can accomplish the same function. One would be to print a Location: /path/to/file.exe instead of the header. That will cause most (if not all) browsers to redirect directly to the file.

If the purpose of the script is to track how many times the file is downloaded, you should move the file outside of a public directory. As it stands now, anyone that knows the direct link to the file can download, thus bypassing your logging.

Also, just for reference, a more perlish way of writing your code (not that I am endorsing your method of solving your problem, but..) it would be:

#!/usr/local/bin/perl -w use strict; my $FILE= "/home/username/cgi-bin/test/file.exe"; print "Content-Type: application/octet-stream\n\n"; open(FH, $FILE) || die "Can't access file: $_\n"; print <FH>; close(FH);