right tool for the job
Kevin D. Clark
kclark at CetaceanNetworks.com
Thu Mar 4 11:02:51 EST 2004
Rob Lembree writes:
> So for example, I want to grab a whole directory hierarchy
> such as 'files', but exclude subdirectory 'exclude', but
> include subdirectory 'exclude/include'
>
> files
> files/exclude <---- this directory is excluded
> files/exclude/include <---- except this directory or file
> files/exclude/others...
This comes to mind:
#!/usr/bin/perl
use File::Find;
find(sub {
if ($File::Find::name =~ /exclude(.*)?$/) {
if ($1 =~ m#^/include(/|$)#) {
print $File::Find::name, "\n";
}
} else {
print $File::Find::name, "\n";
}
}, ".");
Of course, you can easily generalize this to your particular problem.
Hope this helps,
--kevin
--
Kevin D. Clark / Cetacean Networks / Portsmouth, N.H. (USA)
cetaceannetworks.com!kclark (GnuPG ID: B280F24E)
alumni.unh.edu!kdc
More information about the gnhlug-discuss
mailing list