- 论坛徽章:
- 0
|
如题,请教各位。新手,不好意思,测试了很久,太耽误时间了。
代码如下:
思路:输入一个要查询的字符串,检查某个目录下所有文件名是否有匹配的。如果有,则返回所有匹配的文件名。
use 5.010;
use Cwd;
chomp( $mydir = cwd);
#@myfiles = glob "$mydir/xiaoyangtuo/*";
@myfiles = glob "$mydir/xiaoyangtuo/*";
#print "\@myfiles are: @myfiles\n";
print "input a pattern as part of file name for earhing: \n";
chomp ($mypattern =<STDIN>);
while ($mypattern) {
@myfile_search = map /$mypattern/g, @myfiles;
#@myfile_search = map /$mypattern/g, glob(".* *"); #this line should go with chdir which is not correct right now;
print "myfile_search is: @myfile_search \n";
chomp ($mypattern =<STDIN>);
} |
|