in reply to How to escape parens for grep

Show us the code that you have tried so far. Which parts of the line can change and which parts stay the same?

You could consider using a regex (see perlretut) along these lines:

my ($part1, $part2, $part3, $part4) = $line =~ /"some text \((.*?)\) more text (.*?) and dst text (.*?) -flag (.*?)"/;

which would match "some text (6's and 7's) more text fred and dst text joe -flag /tmp/filename" and would set the variables as:

$part1 = 6's and 7's $part2 = fred $part3 = joe $part4 = /tmp/filename

You will need to adjust the example for your particular problem, but the essence is there.


Perl is Huffman encoded by design.