inverse pattern matching!!!

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Background: I have a little program that scans pathnames and does
something worthile if a match is generated. Equally, I have a config
file with lines representing patterns to skip. To skip lines I have
the following (sort of):
if ($pathname =~ m,^$pattern$,) {;#skip it} else {;#do something

Initially I want to skip home directories: '/home/.*' worked a treat.
Now I need to skip all, but not anything with '.ssh' in it.
so '/home/fred/.ssh' or '/home/tom/.ssh/known_hosts' is not excluded.

Now I know this must be simple but can I figure out a clean inverse of

Any ideas gurus?

Re: inverse pattern matching!!!

Quoted text here. Click to load it

Use negative lookahead.

It would be more efficient to reverse (or extend) the logic in
configuration processing (that is, make positive selection possible).


Site Timeline