プロが教える店舗&オフィスのセキュリティ対策術

CGI初心者です。
(osはlinuxです。)

#!/usr/local/bin/perl
use strict;
use CGI;
my $file=new CGI;
open(DATA,"/home/data.txt");
$file=<DATA>;
close=(DATA);
print "Content-type: text/html\n\n";
print "data=$file";

このスクリプトで、/home/data.txt(フルパスです)に書かれているデータを1行だけをブラウザで表示させたいのですが、表示できません。
どこがおかしいのか教えてください。
ちなみにdata.txtには実際に「abc」という文字1行しか入れていません。

A 回答 (1件)

>type sample.pl


#!/usr/local/bin/perl
use strict;
use CGI;
my $file=new CGI;
open(DATA,"/home/data.txt");
$file=<DATA>;
close=(DATA);
print "Content-type: text/html\n\n";
print "data=$file";

>perl -c sample.pl
Can't modify close in scalar assignment at sample.pl line 7, near ");"
Bareword "DATA" not allowed while "strict subs" in use at sample.pl line 7.
sample.pl had compilation errors.

サーバーに持っていって実行する以前の問題。
入門書をもう一回よく読むことをオススメします。
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!