Ilia Ross
Ilia Ross

Reputation: 13404

PERL regex matching lines containing certain directory path

What is the best way to use regular expression in Perl for filtering all lines containing, for instance /usr/libexec/postfix?

That would also catch, e.g.: /usr/libexec/postfix/qmgr, /usr/libexec/postfix/smtp, /usr/libexec/postfix/local and so forth?

Upvotes: 0

Views: 1099

Answers (1)

mvp
mvp

Reputation: 116068

This should work:

if ($line =~ m{^/usr/libexec/postfix.*}) {
     print "Match!\n";
} else {
     print "No match\n";
}

Working example: http://codepad.org/jkVlISdv

Upvotes: 3

Related Questions