in reply to Best Way to Search and Delete files on a large Windows Filesystem

Ok. The problem you had with File::Find (which I personally would feel more comfortable with, ive never even heard of File::Recurse) is that you didnt use the option no_chdir and/or you didn't use $File::Find::name. (Actually I have serious reservations about using a module that isnt in the standard distro when there is one in the standard distro that does the same thing. Theres good reason why it got into the standard distro in the first place.)
use strict; use warnings; use File::Find; # Extensions to match my @exts=qw(.nsf .exe); my $search_root='D:\\Bin\\'; # where to start the search # Build a regex my $rexstr=join'|',map {quotemeta $_} @exts; my $rex=qr/(?:$rexstr)$/i; # list of filespecs my @list; # Find em thanks find({ wanted =>sub{push @list,$_ if (/$rex/ && -f)} , no_chdir => 1 } +, $search_root); # And print em out print join "\n",@list;
Adding the email code and etc is left as an exercise for the read... ;-)

BTW: Ive found there is a cute little trick with File::Find under windows. If you use MS style paths (ie backslashes) and dont take advantage of perls ability to handle either then File find will return paths like

D:\Bin\/autoruns.exe
Which means that you can easily tell where the childrens path starts by looking for slashes and not backslashes. (Dont worry about \/ Perl handles it transparently.) But be aware that using the trick makes your code completely unportable.

HTH

Yves / DeMerphq
--
When to use Prototypes?
Advanced Sorting - GRT - Guttman Rosler Transform

Replies are listed 'Best First'.
Re: Re: Best Way to Search and Delete files on a large Windows Filesystem
by perrin (Chancellor) on Mar 08, 2002 at 18:05 UTC
    I use File::Spec->canonpath($File::Find::name) to get cleaned up paths on Win32. Note that Cygwin and ActiveState handle paths a little bit differently. I generally prefer the way ActiveState does it.
      Yeah ive done the same thing, although I generally use regexes if the output is from File::Find. But my point was that using the path as returned is fine and that taking advantage of the backslash change can be quite useful. For instance for creating a HOH of the directory structure. You can just do something like
      my($root,$path)=$funnyspec=~m!([^/]+)([^\]+)!; my @parts=split('/',$path);
      (well YKWIM)

      Anyway, I have to admit that I almost never use my cygwin version of Perl.

      Yves / DeMerphq
      --
      When to use Prototypes?
      Advanced Sorting - GRT - Guttman Rosler Transform

Re: Re: Best Way to Search and Delete files on a large Windows Filesystem
by Anonymous Monk on Mar 08, 2002 at 18:03 UTC
    perl experts,
    Can you show the whole code when you get it working so I can learn from it?