Reputation: 13404
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
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