Wouldn't it be easier to do a redirect? You are in fact just
writing your own webserver here. I suppose you have
a good reason to give them the correct data from the wrong
URL tho. I've seen a site where half the content was at
/error.pl before. Plays havok with caching =) Your webserver
at least TRYS to give good header...