The problem is not that Perl or CGI ignores the # anchor, the problem is that the browser does not send the anchor data to your server in the first place. A Javascript function might work for clicked links, but I can't think of any way to capture that information for a pasted link.