title: CGI perl read and print the content of a file
body: <p>I wanted to open a text file and read the first 10 line by using <code>CGI</code> and <code>Perl</code>
  I wrote the script but it does not work. where is my problem</p>
  
  <pre><code>#!C:/wamp/apps/Perl/bin/perl.exe -wt
  
  use CGI;
  my $cgi=CGI-&gt;new();
  
  print 
  $cgi-&gt;header('text/html'),
  $cgi-&gt;start_html('Extract the text'),
  $cgi-&gt;h1({-style=&gt;'color:red;background-color:#eee;'},'Extract CGI'),
  $cgi-&gt;start_form(-enctype=&gt;&amp;CGI::MULTIPART),
  'Upload your text File: ',
  $cgi-&gt;filefield(
      -name=&gt;'filename',
      ),
  $cgi-&gt;submit(-value=&gt;'Read the File'),
  
  my $txtfile=$cgi-&gt;param('filename'),
  
  open my $in,$filename or die("couldnot open");
  while (my $line = &lt;$in&gt;)
  {
      print $line;
      last if $. == 10;
  }
  close $in;
  
  $cgi-&gt;end_form;
  $cgi-&gt;end_html;
  </code></pre>