For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > October 2005 > File::Find Win32 Examples









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author File::Find Win32 Examples
BartlebyScrivener

2005-10-26, 6:56 pm

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.

Reinhard Pagitsch

2005-10-27, 7:55 am



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
BartlebyScrivener

2005-10-27, 6:56 pm

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

Reinhard Pagitsch

2005-10-27, 6:56 pm

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
BartlebyScrivener

2005-10-27, 6:56 pm

It works! Thanks so much for your help.

bs

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com