in reply to do $n exist in grep?
map { /^..(A|B)./ ? [ $_, $1 ] : () } @a
I got the sense that you didn't want just the captured parts. But if you only need the $1 from each match the above simplifies to
map { /^..(A|B)./ ? $1 : () } @a
but you could also go a step further and simply use
map /^..(A|B)./, @a
Update: Added what's after the break.
Seeking work! You can reach me at ikegami@adaelis.com
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: do $n exist in grep?
by Marshall (Canon) on May 12, 2021 at 16:19 UTC | |
by davido (Cardinal) on May 12, 2021 at 16:58 UTC | |
by choroba (Cardinal) on May 12, 2021 at 17:02 UTC | |
by davido (Cardinal) on May 12, 2021 at 17:26 UTC | |
by Marshall (Canon) on May 12, 2021 at 20:46 UTC | |
|
Re^2: do $n exist in grep?
by ikegami (Patriarch) on May 12, 2021 at 17:11 UTC |