我在用Eclipse + EPIC学perl。刚刚想用perl打开D盘根目录下面一个文本文件然后执行读操作,但是发现打不开,感到很奇怪。
我的代码如下:
open (FH, "D:/DNA.txt");
$test = ;
close FH;
print "This is the result: \n";
print $test;
exit;
Run后Eclipse输出结果如下:
This is the result:
readline() on closed filehandle FH at D:/ElipseWorkspace for perl/MyRSSFeeder/try.pl line 2.
Use of uninitialized value $test in print at D:/ElipseWorkspace for perl/MyRSSFeeder/try.pl line 5.
DNA.txt确定存在,请问大家这是怎么回事?
#!perl -wuse strict;open (FH, "D:\\DNA.txt")
or die "Can't open DNA.txt, $!";print "This is the result:\n";while (my $test = ) {
print $test;}close FH;...
shinra13 :在错误提示中我们可以看到。Use of uninitialized value $test in print at D:/ElipseWorkspace for perl/MyRSSFeeder/try.pl line 5.只需要在$test = ; 改为my $test = ;然后close放到程序的最后。...