Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: do $n exist in grep?

by ikegami (Pope)
on May 12, 2021 at 17:11 UTC ( #11132506=note: print w/replies, xml ) Need Help??


in reply to Re: do $n exist in grep?
in thread do $n exist in grep?

I got the sense that you didn't want just the captured parts. But if you only need the $1 from each match,

map { /^..(A|B)./ ? [ $_, $1 ] : () } @a

simplifies to

map { /^..(A|B)./ ? $1 : () } @a

but you could also go a step further and simply use

map /^..(A|B)./, @a

(I added this to the original post to show the options in one place.)

Seeking work! You can reach me at ikegami@adaelis.com

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11132506]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (1)
As of 2021-08-04 03:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My primary motivation for participating at PerlMonks is: (Choices in context)








    Results (41 votes). Check out past polls.

    Notices?