Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^11: Restrict file search within current filessystem using wanted subroutine

by haukex (Archbishop)
on May 18, 2016 at 19:37 UTC ( [id://1163369]=note: print w/replies, xml ) Need Help??


in reply to Re^10: Restrict file search within current filessystem using wanted subroutine
in thread Restrict file search within current filessystem using wanted subroutine

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,
-- Hauke D

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1163369]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-19 23:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found