Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Re: Deleting Files

by McD (Chaplain)
on Feb 24, 2001 at 02:57 UTC ( #60575=note: print w/replies, xml ) Need Help??


in reply to Re: Deleting Files
in thread Deleting Files

Adam writes:

Hmmm, File::Find is really for delving into the subdirs,

I know, and it's difficult to grok sometimes how to use it correctly - the whole "prune/not prune" thing is still unclear to me. But besides that...

and if you don't want that, then just glob(*) like this:

For a while now I've been pondering which was faster, a glob or a readdir, so I decided to test it on a big directory I've got lying around (36K files).

The answer?

glob failed (child exited with status 1) at trial.pl line 12.

Nuts. Do I recall somewhere that Perl relies on the shell for globbing in some way? If so, going with a readdir on a big directory may be your only choice.

As for speed issues, you have to loop over everyfile, no matter what,

And, although I can't speak for NTFS/HPFS/FAT filesystems, I know that a flat directory on Solaris or Linux is going to be a serious dog to scan over 1000 files, no matter what.

Implement a heirarchical subdirectory scheme - maybe based on the date, which would simplify purging, too.

That's what I did, faced with a similar problem, anyway. :-)

Peace,
-McD

Replies are listed 'Best First'.
Re (tilly) 3: Deleting Files
by tilly (Archbishop) on Feb 24, 2001 at 03:47 UTC
    With Perl 5.6 globbing no longer uses the shell.

    As for the filesystem, ReiserFS on Linux is supposed to handle that kind of directly smoothly. However ext will slow to a crawl, and NTFS appears to as well.

    The problem, of course, is that every mention of a file requires scanning the list of things in the directory, which means that you scan a list of many thousands of files many thousands of times. Unless the filesystem is designed for that, you have a problem.

    Recommended solutions? Hierarchical structures (which is what most filesystems are designed to do), a dbm, a

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2022-10-07 23:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (30 votes). Check out past polls.

    Notices?