On 7/12/06, Nishi Bhonsle <[EMAIL PROTECTED]> wrote:
Hi:
Sorry to start this thread again, but it would not have been wise to ask my
related question in a different thread.
I tried to run the program on a windows machine, apparently the regex in
question only lists directories within directories and not the files within
the directories.
I tried Rob's regex as well as Randal's.
In addition how can I modify the code, so that the buildlist.txt only lists
the files within the directories and not the directories?

TIA!

Nishi,

Several people have suggested File::Find. You should really look it up
on cpan. But since you asked about readdir...

readdir() lists everything in the directory; files, directories,
everything. If you're not seeing any files, you're reading a directory
that only contains other directories.

If you wan't to get only the files in a directory that contains files
and directories, you need to test whether the handles are files or
something else with a file test; readdir() just returns names.
Something like this should get you started:


  opendir(DIR, $somedir) or die "$!\n";
  my @files = grep { $_ !~ /^\.{1,2}$/ && -f "$somedir/$_" } readdir(DIR);
  closedir(DIR);

While we're on the subject, the regex doesn't list anything. readdir()
lists. grep() uses the rexes to take what you don't want out of the
list. The only files the regex is removing are files with names that
are entirely strings of periods. If you're not seeing what you think
you should be seeing, make sure your script is running from the
correct directory.

HTH,

-- jay
--------------------------------------------------
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.dpguru.com  http://www.engatiki.org

values of β will give rise to dom!

Reply via email to