【发布时间】:2014-03-27 09:03:08
【问题描述】:
我有一个这样的示例代码:
#!usr/bin/perl -w
my $path = shift;
my $max_number_of_files = shift;
print("Changing directory to path $path $!" . "\n");
chdir($path) or die "Cant chdir to $path $!";
print("Counting files..." . "\n");
counting();
sub counting {
$counted = system("ls -1 | wc -l");
if ($counted > $max_number_of_files) {
print("You have more or equal files");
return 1;
}
else {
print("$counted");
print "You have less files";
return 2;
}
}
但我的价值 $counted 我认为没有得到系统命令显示到控制台的值。我检查了它,它总是为零。我该如何处理?
【问题讨论】: