title: Perl CGI to download a file via web browser
body: <p>Need some cgi-perl script which can download a file from a server machine.  EX: click on a download link and it will open a "save as"
  window and will allow me to save the file on my local machine.</p>
  
  <p>I have created a web page using CGI, using this I will upload a file to server and will run a perl script to convert it to some other format (till here I am done). Now I need get this file back (download back) to the system.</p>
  
  <pre><code>#!/usr/bin/perl
  #print "Content-type: text/html\n\n";
  my $filepath='/upload/testing.pm';
  
      print "Content-Type: text/html\n\n";
  
      open("DOWNLOADFILE", "&lt;".$filePath);
      while($fileContents = &lt;DOWNLOADFILE&gt;) {
          print $fileContents;
      }
  print "Content-Type: text\n";
  print "Content-Disposition: attachment; filename='testing.pm'\n";
  print "Content-Description: File to download\n\n";
      close DOWNLOADFILE;
  </code></pre>
  
  <p>Upload a file from my machine (client) to server machine, where I have a perl script which will convert the file to another format and will save the newly converted file to a dir ex: /upload-> till here I am done with scripting. </p>
  
  <p>Now I need to download this file back to client machine using browser. In this case I was trying to download testing.pm file back to client machine.</p>