- 论坛徽章:
- 0
|
起因是我看了这篇
于是我做了些修改为什么呢,以我的理解结果应该是
atiking 发表于 2010-12-16 17:32 ![]()
From "perldoc -f glob":
In scalar context, glob iterates through ... filename expansions,
returning undef when the list is exhausted.
So glob() is returning the file pattern itself on the first call, as
Charles described, and then undef on the second call to indicate that
the list is complete. The cycle continues on the third call and so on.
To avoid this effect, call glob() in list context, like this perhaps:
for (1..10) {
if (my @x = glob "foo.$_") {
print "@x\n";
print "yes";
}
else {
print "@x\n";
print "no";
}
print "-------------";
}
HTH,
Rob |
|