我必须读取perl脚本中的文件。我已经做了什么,我已经找到了大部分的资源都告诉我这样做,但我仍然得到同样的错误,这里是我的代码:无法打开文件在perl中读取
print "Input file name: ";
$file = <>;
open($fileHandle, "<", $file) or die "cannot open < $file: $!";
结果:
cannot open < scores.dat
: No such file or directory at ./project5.pl line 6, <> line 1.
这样做我每次都得到错误。任何想法,我是新来的Perl,所以我准备犯一个愚蠢的错误,但是,是的,scores.dat确实存在。
仅供参考:http://perldoc.perl.org/functions/chomp.html – chilemagic