in reply to Downloading a file

my ($filepath,$filename) = @_;

That code is probably wrong, but I can't tell because you didn't show how you're invoking this program or script or fragment or whatever. How do you get the filepath and filename from the request?