k-man has asked for the wisdom of the Perl Monks concerning the following question:
I'm getting a count of lines matching a pattern.
This code works:
ACTION_PATTERN='perl$' export ACTION_PATTERN ROWS=$(perl -n -e '$count++ if /$ENV{ACTION_PATTERN}/; END { print $co +unt }' ~/.zsh_history) echo "ROWS:${ROWS}"
Is there a simpler alternative to exporting?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Calling perl from zsh w/ vars
by hippo (Archbishop) on Jul 18, 2020 at 11:33 UTC | |
by k-man (Novice) on Jul 22, 2020 at 11:04 UTC | |
|
Re: Calling perl from zsh w/ vars
by AnomalousMonk (Archbishop) on Jul 18, 2020 at 15:15 UTC | |
|
Re: Calling perl from zsh w/ vars
by Fletch (Bishop) on Jul 20, 2020 at 18:46 UTC | |
|
Re: Calling perl from zsh w/ vars
by Marshall (Canon) on Jul 18, 2020 at 11:44 UTC | |
by karlgoethebier (Abbot) on Jul 18, 2020 at 15:24 UTC | |
by Marshall (Canon) on Jul 20, 2020 at 03:27 UTC | |
by karlgoethebier (Abbot) on Jul 20, 2020 at 05:40 UTC | |
by Anonymous Monk on Jul 18, 2020 at 13:06 UTC |