$File::Find

P

Pierre-Yves

Hello,

I have to loop recursively in directories to build a tree. Based on the
directory name, I know I can skip some (i.e: the BACKUP ones) to improve the
performances that are currently very bad :

At the moment I use find(&listFolders, $entrypoint)
In the sub "listFolders" I do $File::Find::name if -d && !/^.$/;
It works but but it's terribly slow and since it's used in a CGI, I can't
let the users wait several minutes each times.
I tried to add "next if /\/BACKUP$/;" but it doesn't seems to work.

here is how the directory structure looks like :

/source/
/répertoire1
/répertoire11
/répertoire111
/BACKUP
...
/répertoire12
/BACKUP
/répertoire2
/répertoire21
/BACKUP
...
...


If someone can help, I would really appreciate... I'm new at Perl and I'm
not yet very familiar with this language.

Thanks in advance !
 
N

nobull

Pierre-Yves said:
Hello,

I have to loop recursively in directories to build a tree. Based on the
directory name, I know I can skip some (i.e: the BACKUP ones) to improve the
performances that are currently very bad :

At the moment I use find(&listFolders, $entrypoint)
In the sub "listFolders" I do $File::Find::name if -d && !/^.$/;
It works but but it's terribly slow and since it's used in a CGI, I can't
let the users wait several minutes each times.
I tried to add "next if /\/BACKUP$/;" but it doesn't seems to work.

It's not quite clear what you are asking but I suspect you want to say

$File::Find::prune = 1 if $_ eq 'BACKUP';

Unfortunately the File::Find documentation doesn't go into much detail
about the prune facility because (I suspect) when File::Find was
written it was assumed that everyone was familar with the Unix find
command.

This newsgroup does not exist (see FAQ). Please do not start threads
here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top