in reply to security issues with an index.pl-type thing...
That works. Basically you need to untaint the value you were passed after making sure it is valid. Checking it against a hash of valid values will do the trick, or as this site does, looking it up in a database.
Make sure that you use the correct filename portion of the URL (stip off arguments, add the absolute path if needed, etc.) when you do the validation.
It also might make some sense to not have a subroutine to open the filehandle, but rather just get the filename from the validator and have a standard block of code open it.