我想打开一个文本文件并通过使用读取前 10 行CGI
,Perl
我编写了脚本,但它不起作用。我的问题在哪里
#!C:/wamp/apps/Perl/bin/perl.exe -wt
use CGI;
my $cgi=CGI->new();
print
$cgi->header('text/html'),
$cgi->start_html('Extract the text'),
$cgi->h1({-style=>'color:red;background-color:#eee;'},'Extract CGI'),
$cgi->start_form(-enctype=>&CGI::MULTIPART),
'Upload your text File: ',
$cgi->filefield(
-name=>'filename',
),
$cgi->submit(-value=>'Read the File'),
my $txtfile=$cgi->param('filename'),
open my $in,$filename or die("couldnot open");
while (my $line = <$in>)
{
print $line;
last if $. == 10;
}
close $in;
$cgi->end_form;
$cgi->end_html;