g1smd - 12:16 am on Jan 21, 2013 (gmt 0)
For products that go away and are never coming back, returning 410 Gone is appropriate.
For paginated lisings, e.g categories, return 404 Not Found when higher-numbered pages are gone because they may well come back.
I believe that all scripting languages allow you to override the HTTP headers and send something other than 200 OK.
Returning 404 Not Found from within your PHP or Perl script won't invoke your global error page. Once your PHP or Perl script is dealing with the request, you're way past the parts of Apache that check whether the request will resolve to a file and invoke error messages if not.
The usual method in PHP is to send the 404 HTTP header and then "INCLUDE" the file that contains the human readable 404 error message. I assume that Perl has some equivalent.