- 论坛徽章:
- 0
|
perl语言入门里模块的内容很少内容都是是带过的,看得 不怎么懂,参数什么的不太会用。
参考前辈写了一段清除目录下的.tmp文件的程序,请问哪里错了?
#!/usr/bin/perl
use strict;
use File::Find;
sub wanted{
if(-f $File::Find::name){
if($File::Find::name=#\.tmp#i){
print"Removing $File::Find::name\n";
unlink $File::Find::name;
}
}
}
find(\$wanted,'/usr/local/hup_perl/tmpfile');
#我的疑问:
1.File::Find::name ,find ---等这几项大小写是规范呢还是必须这么写的?区别大小写吗?
2.Find是模块名,name和find 是这个模块能调用的方法吗?
3.参数 sub wanted 这2个是什么意思啊?以及后面的find(\$wanted,'')?
4.以上编译出错了,提示:
syntax error at ./test line 7, near ""Removing $File::Find::name\n";"
Unmatched right curly bracket at ./test line 11, at end of line
syntax error at ./test line 11, near "}"
Execution of ./test aborted due to compilation errors. |
|