> -----Original Message-----
> From: Ben Crane [mailto:[EMAIL PROTECTED]]
> Sent: Monday, November 12, 2001 1:29 PM
> To: [EMAIL PROTECTED]
> Subject: whats wrong with this?
> 
> 
> hey guys, this file::find problem is getting me
> down...I have tried to simplify it as much as
> possible.
> these 3 files do exist on my c: root. the program
> doesn't find anything if I use a variable in my if
> statement, if I use a constant...bingo...I can't work
> it out...what am i doing wrong?
> 
> #!usr/bin/perl -w
> 
> use File::Find;
> @testarray=qw(test5.pl test6.pl test7.pl);
> 
> find(\&wanted, '.');
>  
> $count=0;
> 
> sub wanted() 
>       
>       {
>       if ($_ eq $testarray[$count])
>       {
>               print $File::Find::name;
> 
> 
>       }
> $count++;
>       }

But this will *only* work if the first file passed to wanted()
is test5.pl, the second is test6.pl, and the third is test7.pl

You should't try to predict which files will be passed in what 
order. Better to use something like this:

   %files = map {$_=>1} qw(test5.pl test6.pl test7.pl);

   ...

   sub wanted
   {
      print "$File::Find::name\n found" if $files{$_};
   }

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to