How to ignore the single and double dot entries in Perl's readdir?

后端 未结 5 925
甜味超标
甜味超标 2021-01-21 05:04

Following up from here: Perl Imgsize not working in loop? I have another question - how do I not let perl list the single and double dot entries when it reads the files in a dir

5条回答
  •  灰色年华
    2021-01-21 05:46

    To test string you have to use eq:

    if($file eq "." || $file eq ".."){ next;}
    

    or:

    next if $file =~ /^\.\.?$/;
    

提交回复
热议问题