0
使用未初始化值誤差從下面的代碼中,我得到錯誤在級聯
Use of uninitialized value $fileName in concatenation <.> or string at ... line 8.
我也得到錯誤
Can't open from: No such file or directory at ... line 8.
這是功課參考示例代碼。我試圖理解它。
use strict;
use warnings;
my $dayLength = $ARGV[0];
my $byteLength = $ARGV[1];
my $fileName = $ARGV[2];
open INPUT, "< $fileName" or die "Can't open from: $!";
my $takeIn = <INPUT>;
print "$takeIn\n";
my @files = split//, $takeIn;
print "@files\n";
foreach my $file (@files){
if(-M $file > $dayLength && -s $file > $byteLength){
print "\n::::::::$file::::::::\n";
open INPUT, "< $file" or die "Can't open from: $!";
my $i = <INPUT>;
while($i = <INPUT>){
print $i;}
}}
第8行是_first_'open INPUT'行,你確定這是正確的代碼嗎? – paxdiablo 2015-04-05 02:31:21
在幻燈片中說第三個參數是輸入文件的名稱 – 2015-04-05 02:35:57
當你運行你的程序時,你是否傳遞了第三個參數?如果沒有,那麼這就是爲什麼'$ fileName'沒有值。 – 2015-04-05 02:38:56