The reason that you have to put in a double \\ instead of a single \ is due to the \ being a reserved character and will not work unless you have a double.
Kinda sucks but you learn to deal with it pretty quickly
-----Original Message-----
From: $Bill Luebkert [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 18, 2002 12:57 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: File::Find question
[EMAIL PROTECTED] wrote:
> Does anyone know why the following code does not work?
>
> ---------
>
> use File::Find;
>
> find (\&wanted, 'C:/');
>
> sub wanted {
> if ( -d && /dllcache/i || /System Volume Information/i ) {
> $File::Find::prune = 1;
> } else {
> next if ( -d || ! /exe$/ && ! /com$/);
> print "$File::Find::name\n";
> }
> }
>
> -------
>
> When this runs, it just immediately exits, but if I replace the search
> directory to something like "C://" or "C:/.", it will work, but I will
> get output in the form of ...
>
> C://WINDOWS/system32/loginw32.exe
>
> I am looking to get output in the form of...
>
> C:/Windows/System32/loginw32.exe
>
> Also, does anyone know of a faster way of inventorying all files on a
> NT/2K/XP based system? I'm currently using the File module, but wasnt
> sure if there was a faster way to do this in Perl.
Watch your operator precedences and next vs return - change c:/ to c:\\:
use strict;
use File::Find;
find (\&wanted, 'C:\\'); # not sure why / isn't working - uses CWD on drive
sub wanted {
if (-d && (/dllcache/i || /System Volume Information/i)) {
$File::Find::prune = 1;
} else {
return if -d || (! /exe$/i && ! /com$/i);
print "$File::Find::name\n";
}
}
__END__
--
,-/- __ _ _ $Bill Luebkert ICQ=162126130
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_</_</_ Castle of Medieval Myth & Magic http://www.todbe.com/
_______________________________________________
Perl-Win32-Admin mailing list [EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
