in reply to check if it is a file or directory

If you don't need to use a while loop, you could get a list of all the directories using the File::Slurp read_dir function which by default ignores the special . and .. directories:
use File::Slurp; my @dirs = grep { -d "$oldFolder/$_" } read_dir($oldFolder); print "$_\n" for @dirs;
This approach is slightly different from yours in that it will not filter out other hidden directories, such as .foo.

Replies are listed 'Best First'.
Re^2: check if it is a file or directory
by saintex (Scribe) on Feb 26, 2010 at 15:18 UTC
    I tought to use a while, because my directory has really a lot of files, so with a while loop was easy to run that program again, also if it fails. If File::Slurp reads all files at once, and it pocesses them later, maybe my program crashes. Please let me know if Slurp acts in that way, or there is some control on directory reading. For that same reason I choose a "while" over any entries and not a "foreach" structure. For that I can understand, "foreach" read all the lines and then process it, but the "while" process all the lines, while reading. Thank you
      File::Slurp will read all directory contents (files and sub-directories) at once. Because your requirement is to process each file one at a time, do not use File::Slurp in this case.
        ok, thank you for your answer!