File::Find Win32 Examples

File::Find Win32 Examples

am 26.10.2005 20:51:07 von BartlebyScrivener

I am trying to learn Perl using the latest ActiveState on a Windows XP
machine.

Most of the examples I find for using modules are made for Linux users.
So when I set out to learn find2perl or File::Find the scripts usually
don't work because of pathname problems, (or so I assume).

Could someone please supply a file::find example for a windows xp
machine?

For instance, my drives are usually partitioned with data on d:\. How
would I search all files on d: drive for any file containing the string
"perl amateur"

Thank you for any help.

Re: File::Find Win32 Examples

am 27.10.2005 12:52:12 von Reinhard Pagitsch

BartlebyScrivener wrote:
> I am trying to learn Perl using the latest ActiveState on a Windows XP
> machine.
>
> Most of the examples I find for using modules are made for Linux users.
> So when I set out to learn find2perl or File::Find the scripts usually
> don't work because of pathname problems, (or so I assume).
>
> Could someone please supply a file::find example for a windows xp
> machine?
>
> For instance, my drives are usually partitioned with data on d:\. How
> would I search all files on d: drive for any file containing the string
> "perl amateur"
>
> Thank you for any help.

More detailed error messages would be helpfull to reproduce the problem.
But it is similar the same as on UNIX/Linux, except that you have to use
/ instead of \.

eg:
my $dir = "D:/test/data";


sub wanted
{
if(!-d $File::Find::name)
{
print $File::Find::name . "\n";
}
}


find(\&wanted, $dir);

--
regards,
Reinhard

Re: File::Find Win32 Examples

am 27.10.2005 16:17:58 von BartlebyScrivener

Thank you very much. I shall take another stab and report back with any
errors.

This line has me stumped:

if(!-d $File::Find::name)

I see != as a comparison operator in my Perl book, but not !-

Thank you again.

BS

Re: File::Find Win32 Examples

am 27.10.2005 16:29:37 von Reinhard Pagitsch

BartlebyScrivener wrote:
> Thank you very much. I shall take another stab and report back with any
> errors.
>
> This line has me stumped:
>
> if(!-d $File::Find::name)
>
> I see != as a comparison operator in my Perl book, but not !-

This !-d tests if the "file" is NOT a directory.
Look in the perlfunc man page for the -X FILEHANDLE.

--
regards,
Reinhard

Re: File::Find Win32 Examples

am 27.10.2005 16:53:21 von BartlebyScrivener

It works! Thanks so much for your help.

bs