这代码在linux跑有什么问题?
windows下正常删除png文件。结果到linux下运行没什么反应。。双引号什么的都试过了,不知原因出在哪里,特请教:
复制代码
然后 perl del_file.pl ./
试过 unlink("$_");或单引号之类的,还是无效。不知是什么原因。linux和windows下的perl代码除了'和"还有其他的区别么?
- #!/usr/bin/perl -w
- #delete files i want.
- use strict;
- use File::Find;
-
- my $dir = "$ARGV[0]";
-
- find (\&wanted,$dir);
-
- sub wanted{
- if(-f $_ and /\.png/i){
- # print "$_\n";
- unlink $_;
- }
- }
试过 unlink("$_");或单引号之类的,还是无效。不知是什么原因。linux和windows下的perl代码除了'和"还有其他的区别么?
作者: perlnewbie 发布时间: 2011-05-29
哈哈,找到原因了。
添加了一句die就知道原因了。
ajq@mint ~/Documents/暗黑女王 $ perl del_file.pl ./
Could not unlink file: Permission denied at del_file.pl line 11.
Could not unlink file: Permission denied at del_file.pl line 11.
Could not unlink file: Permission denied at del_file.pl line 11.
Could not unlink file: Permission denied at del_file.pl line 11.
Could not unlink file: Permission denied at del_file.pl line 11.
Could not unlink file: Permission denied at del_file.pl line 11.
看来die非常重要呀。。嘿嘿。。。
添加了一句die就知道原因了。
ajq@mint ~/Documents/暗黑女王 $ perl del_file.pl ./
Could not unlink file: Permission denied at del_file.pl line 11.
Could not unlink file: Permission denied at del_file.pl line 11.
Could not unlink file: Permission denied at del_file.pl line 11.
Could not unlink file: Permission denied at del_file.pl line 11.
Could not unlink file: Permission denied at del_file.pl line 11.
Could not unlink file: Permission denied at del_file.pl line 11.
看来die非常重要呀。。嘿嘿。。。
作者: perlnewbie 发布时间: 2011-05-29
作者: zhlong8 发布时间: 2011-05-29
楼主文件名好邪恶。。。
作者: toniz 发布时间: 2011-05-29