jim wrote:
> 
> i wrote the code below to find all files ending in '.plx' then tell me where
> they are. it is suppose to print out the unique directories only. but it
> seems to be printing out redundantly as many times as there are .plx files
> in that same directory.
> can anybody tell me what's wrong with my code?
> thanks for you help!
> jim
> 
> use File::Find;
> 
> find(\&wanted, "c:/perluser/");
> 
> sub wanted {
>  my @dir = "$File::Find::dir"if m/\w\.plx/i;
>  print "@dir\n";
>  my %seen;
>  my @unique_dir = grep {! $seen{$_}++} @dir;
>   foreach $dir_in (@unique_dir) {
>    #print "$dir_in\n";
>    $count++
>   }
> }
>  print "\n", 'There are ', "$count", ' files', "\n";


Is this what you want?

#!perl.exe -w
use File::Find;
use strict;
my %dir;
my $suffix = "plx";
find(\&wanted, "c:/perluser/");
for (keys %dir) {
        print "$_ -> $dir{$_} \'$suffix\' files\n"
}
sub wanted {
        return unless /\.$suffix/i;
        $dir{"$File::Find::dir"}++;
        1;
}

-- 

Best Regards,

mds
mds resource
888.250.3987

"Dare to fix things before they break . . . "

"Our capacity for understanding is inversely proportional to how much we
think we know.  The more I know, the more I know I don't know . . . "
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web

Reply via email to