in reply to Re^17: How do I use grep in a script
in thread How do I use grep in a script

There is a glitch in the way Acct: is searched for.

I need to delimit each record by "STATUS Acct:"

My attempts are producing no results

if (/\"STATUS Acct:\"(\d+)/)

I think I would need to escape the quotes, but maybe not?

I can grep this from the command line and get the correct results without escaping the quotes.

Any Ideas?

Replies are listed 'Best First'.
Re^19: How do I use grep in a script
by poj (Abbot) on Dec 29, 2017 at 15:08 UTC

    If you don't need to keep the quotes just remove them before the match

    while (<$fh>){ next unless /\S/; # skip blank lines s/"//g; # remove all "

    or if they are optional try

    if (/STATUS\s+Acct:"?(\d+)/){ $acct = $1; }

    See perlretut

    poj
      Got it poj -- THANKS