Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: Regular expression to list all files of type in folder

by runrig (Abbot)
on Dec 05, 2012 at 21:47 UTC ( #1007408=note: print w/replies, xml ) Need Help??

in reply to Regular expression to list all files of type in folder

Did you put a print "$file\n" before the "next unless" to see if the file even gets returned by readdir?

Also, unless you're using autodie, you should check the status of open and opendir.

Replies are listed 'Best First'.
Re^2: Regular expression to list all files of type in folder
by Phinix (Acolyte) on Dec 05, 2012 at 23:55 UTC

    I skipped the "or die" checks because this is just a quick hack to populate the files I need to include in my PARPacker build list. I agree though this should always be done.

    I just checked on your suggestion and you are right, readdir is the one not picking up the similarly named files, though I have absolutely no idea why.

    There are no strange files present. No file named "0" or any weird symbols (not that it should matter). It is basically just a folder full of a couple hundred .jpg files with simple names.

    I'm using Perl 5.12 so the use in a while loop should be no problem.
      what do you get from

      print join "\t", <$dir/*>

      maybe you confused the path?

      'C:/Some/Random/Folder/tmp/bin' ne "C:\\Some\\Random\\Folder\\perl\\bin\\"

      Cheers Rolf

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1007408]
[stevieb]: first real test using CLion with a Perl/C/XS project...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2017-02-22 01:50 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (322 votes). Check out past polls.