in reply to Calling perl from zsh w/ vars

Not a Perl solution, but you can simply unquote the var:

ACTION_PATTERN='perl$' ROWS=$(perl -n -e '$count++ if /'$ACTION_PATTERN'/; END { print $count + }' ~/.zsh_history) echo "ROWS:${ROWS}"

Caveat: only tested in bash. I'd be surprised if it didn't work in zsh too, though.

Replies are listed 'Best First'.
Re^2: Calling perl from zsh w/ vars
by k-man (Novice) on Jul 22, 2020 at 11:04 UTC

    Indeed, thanks