Now you can call the script like so:use strict; use warnings; use File::Find; use Getopt::Long; use vars qw($all @datein @exts @excl $base); GetOptions( 'exts|t=s' => \@exts, 'excl|c=s' => \@excl, 'base|b=s' => \$base, 'all|a' => \$all, ); if (not $all) { @exts = qw( jpg gif tar gz bat txt ) unless @exts; @excl = qw( winnt cygwin ) unless @excl; } $base ||= '/cygwin'; my $exts = join '|', map{quotemeta} @exts; my $excl = join '|', map{quotemeta} @excl; find( sub { push @datein, $File::Find::name if !$exts or m/\.(?:$exts)$/oi and $File::Find::name !~ m!/(?:$excl)!oi ; }, $base, ); print "$_\n" for @datein;
./find.pl -exts=txt -exts=gif -excl=nodes -base=.or this if you want everything:
./find.pl -base=/ -allIf specifying the extensions one at a time becomes too tedious for you, you can rewrite the code to allow the user to pass a delimited string instead. Read up on the Getopt::Long docs for more info. Additionally, check out the Unix command find.
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
In reply to (jeffa) 3Re: Need help with File::Find
by jeffa
in thread Need help with File::Find
by ppm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |