good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re^11: Restrict file search within current filessystem using wanted subroutineby haukex (Archbishop) |
on May 18, 2016 at 19:37 UTC ( [id://1163369]=note: print w/replies, xml ) | Need Help?? |
Hi Madparu, For exact matches you could use a hash. Before your call to find add: my %EXCLUDES = map {$_=>1} ( '/var/log/test.out', '/var/log/new.out', ); and change your condition to return if $EXCLUDES{$File::Find::name};. The first piece of code builds a hash from a list of strings, where the keys of the hash are the strings and the values are just 1, and then the condition checks to see if a hash entry with the key $File::Find::name exists and has a true value. An alternative might be to switch back to regex matches, e.g. return if $File::Find::name =~ m{^/var/log/(?:test|new)\.out$}; Considering that I've been writing your script for you piece by piece, now might be a good time to invest some time into learning more about Perl. Have a look at perlintro, Getting Started with Perl, http://learn.perl.org/ or perhaps the books Learning Perl or Modern Perl (the latter is free). And if you run into questions or trouble, of course feel free to ask here - see How do I post a question effectively? Hope this helps,
In Section
Seekers of Perl Wisdom
|
|