I'm a beginner in perl, and I'm not sure if it's possible.

I want to make a link, say: .../mydownloadscript?

in other word, I want to pass the "" argument to the script, and when I processed othet things in the script (like a counter or such), I want the browser to start downloading the file.

I know that I can just use the Print "Location:\n\n" to start the download (probably) but I don't know how to get that link into the script...

Is it even possible? Thanks!
Who is Participating?
helverConnect With a Mentor Commented:
If you want the link embedded in the URL, you'll need to escape the string that represents the link in order to pull out the characters that would confuse the URL.

I know there's a URI::escape() method that does it.  And I believe there is also a CGI::escape() method that will convert a string to a char sequence usable in a URL.  This would imply that you'd be willing to generate the page that contains the link as well.
If you are asking how you could separate the part after the '?' from the link for the script, its easy.

When you are running this as a CGI script, the string after the '?' is already saved in the environment variable QUERY_STRING. So, all you have to do is:

print "Location: $ENV{QUERY_STRING}\n\n";

If this is not what you want, please clarify.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.