ibanix has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks,
I've got a Windows2K file server with over 2 million pdf files. We want to delete any of these pdfs more than X days old (X seems to keep changing). So, I wrote up a script (below) to automate this; I'm using ActivePerl 5.6.
My problem is that the script seems to cause the system to eat up all it's "system cache" memory! The perl process only seems to use nominal amount of memory. I blame Windows 2000, but has anyone else seen this problem? Anything in my script that stands out as bad?
Thanks in advance,
ibanix
I've got a Windows2K file server with over 2 million pdf files. We want to delete any of these pdfs more than X days old (X seems to keep changing). So, I wrote up a script (below) to automate this; I'm using ActivePerl 5.6.
My problem is that the script seems to cause the system to eat up all it's "system cache" memory! The perl process only seems to use nominal amount of memory. I blame Windows 2000, but has anyone else seen this problem? Anything in my script that stands out as bad?
### Delete pdf files older than X days from given directory tree ### use strict; use warnings; use File::Find; my @directories; $directories[0] = $ARGV[0]; my $days_old = $ARGV[1]; finddepth(\&wanted, @directories); # File::Find coderef # Find all PDFs older than given # of days & delete sub wanted { # Turn forward slashes into backslashes to make real Win32 paths my $file = $File::Find::name; $file =~ s|/|\\|g; if ( ($file =~ m|\.pdf$|) && (int(-M $file) > $days_old) ) { print "Found: $file, deleted\n"; unlink($file) || print "Unable to delete $file!\n"; } }
Thanks in advance,
ibanix
$ echo '$0 & $0 &' > foo; chmod a+x foo; foo;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Some File::Find woes. ($_ not $name)
by tye (Sage) on Jan 12, 2004 at 21:50 UTC | |
by ibanix (Hermit) on Jan 13, 2004 at 20:14 UTC | |
Re: Some File::Find woes.
by bluto (Curate) on Jan 12, 2004 at 23:50 UTC | |
Re: Some File::Find woes.
by Tommy (Chaplain) on Jan 13, 2004 at 00:52 UTC | |
by dominix (Deacon) on Jan 13, 2004 at 11:04 UTC | |
by cLive ;-) (Prior) on Jan 13, 2004 at 05:03 UTC | |
Re: Some File::Find woes.
by paulbort (Hermit) on Jan 13, 2004 at 18:39 UTC | |
by Tommy (Chaplain) on Jan 15, 2004 at 23:07 UTC | |
Re: Some File::Find woes.
by scratch (Sexton) on Jan 13, 2004 at 18:01 UTC |
Back to
Seekers of Perl Wisdom