Necos has asked for the wisdom of the Perl Monks concerning the following question:
The only problem with this code, is that it only seems to work on some directories and not others... Any further guidance is appreciated.#!/usr/bin/perl -w recurse('c:'); #testing this on a windows machine sub recurse { my $dir = shift; #print $dir,$/; opendir(R,$dir) || die $!; my @dives = grep { $_ ne '.' && $_ ne '..' && -d $_ } readdir(R); +#build a list all of the directories @dives = map { join('/',$dir,$_) } @dives; print "$_\n" for @dives; my @contra_band = ('avi','mp3','mp2','mpeg'); my @found; foreach my $a (@contra_band) { my @del = grep { $_ =~ /\Q$a\E$/ } readdir(R); #look for the f +ile extensions map { push(@found,$_) } @del; #create an array of things to un +link later print @del; } map { recurse($_) } @dives; #couldn't think of a for loop to do the + same thing... I don't know what is wrong with me today. }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) Re: Recursing subdirectories for contraband...
by jeffa (Bishop) on Jun 10, 2002 at 18:30 UTC | |
|
Re: Recursing subdirectories for contraband...
by Beatnik (Parson) on Jun 10, 2002 at 18:29 UTC |