tel2
asked on
Multi pattern match
UNIX has a "-E" switch to allow its grep utility to match multiple patterns at once, eg:
grep -E "abc|def|ghi|jkl" infile
will match all lines in infile which contain "abc" or "def", etc.
I know Perl has a "grep" command, and I know it can also do pattern matching with the "=~" operator, but how can I write CONCISE Perl code to match multiple patterns with the:
1. grep command?
2. "=~" operator?
Thanks.
grep -E "abc|def|ghi|jkl" infile
will match all lines in infile which contain "abc" or "def", etc.
I know Perl has a "grep" command, and I know it can also do pattern matching with the "=~" operator, but how can I write CONCISE Perl code to match multiple patterns with the:
1. grep command?
2. "=~" operator?
Thanks.
print grep /abc|def|ghi|jkl/ <>;
print grep /abc|def|ghi|jkl/,<>;
ASKER
ozo,
Is this an answer to both questions, or just #1? If just #1, are there any other commands (eg: "=~") which allow for multiple pattern matching, if so, please give examples.
What does the "<>" mean exactly?
Is this an answer to both questions, or just #1? If just #1, are there any other commands (eg: "=~") which allow for multiple pattern matching, if so, please give examples.
What does the "<>" mean exactly?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ozo,
Thanks for that.
So, are you saying that "<>" is the same as "readline"?
Thanks for that.
So, are you saying that "<>" is the same as "readline"?