Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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]
[Corion]: For PM, I think we'll create a user "gdpr", who gets assigned the nodes of users who want to give up their user status here.
[marto]: can I nominate users ? :P

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2018-05-22 08:30 GMT
Find Nodes?
    Voting Booth?