我想打开一个文本文件,并使用CGI
和Perl
阅读前10行
我写了剧本,但它不起作用。我的问题在哪里
#!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;
答案 0 :(得分:0)
你可能会发现这个有用的
http://www.sitepoint.com/uploading-files-cgi-perl-2/
基本上,上传的文件名称与从浏览器传入的文件名称相同
您需要先检查先发送的内容