Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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.


Comment on Re: Regular expression to list all files of type in folder
Download Code
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1007408]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (11)
As of 2014-09-23 14:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (222 votes), past polls