title: Perl / CGI: redirect to a different page after downloading a file
body: <p>this is quite a newbie question and I've searched on this topic for a while, but nothing I've found seems to work as described. I have this piece of code, for providing a file download to the user, which works perfectly:</p>
  
  <pre><code>open(DOC, "&lt;$file_name") or die "$!";
  @textFile = &lt;DOC&gt;;  
  close DOC;
  
  print "Content-Type:application/x-download\n";  
  print "Content-Disposition:attachment;filename=" . $basename . "\n\n";   
  print @textFile;
  </code></pre>
  
  <p>My problem is that after the file-download has started, I would like to redirect the user to a different page. The script above is actually being submitted from a form by another script where I have:</p>
  
  <pre><code>&lt;form action="/cgi-bin/download.pl"&gt;   
      &lt;p&gt; some msg &lt;/p&gt;  
      &lt;p&gt;&lt;input type="submit" value="Download" name="Download"&gt;&lt;/p&gt;            
      &lt;/form&gt;
  </code></pre>
  
  <p>I've tried putting some javascript statements in the input-Tag like:</p>
  
  <pre><code>onclick="javascript:window.document.location.href=\'http://www.mynewpage.com'
  </code></pre>
  
  <p>as well as printing at the end (of download.pl) something like:</p>
  
  <pre><code>print "Location: http://www.mynewpage.com";
  </code></pre>
  
  <p>It doesn't work.</p>
  
  <p>If someone could give me a hint, I'd really appreciate that!</p>
  
  <p>Thanks in advance!</p>
  
  <p>Alex</p>