这代码在linux跑有什么问题?

windows下正常删除png文件。结果到linux下运行没什么反应。。双引号什么的都试过了,不知原因出在哪里,特请教:
  1. #!/usr/bin/perl -w
  2. #delete files i want.
  3. use strict;
  4. use File::Find;

  5. my $dir = "$ARGV[0]";

  6. find (\&wanted,$dir);

  7. sub wanted{
  8.         if(-f $_ and /\.png/i){
  9. #        print "$_\n";
  10.                 unlink $_;
  11.         }
  12. }
复制代码
然后 perl del_file.pl ./
试过 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非常重要呀。。嘿嘿。。。

作者: perlnewbie   发布时间: 2011-05-29

作者: zhlong8   发布时间: 2011-05-29

楼主文件名好邪恶。。。

作者: toniz   发布时间: 2011-05-29