Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: do $n exist in grep?

by LanX (Cardinal)
on May 12, 2021 at 16:28 UTC ( #11132501=note: print w/replies, xml ) Need Help??


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

DB<31> push @N, /^..(A|B)./ for qw/xxBxx yyAyy zzNzz/ DB<32> x @N 0 'B' 1 'A' DB<33>

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^3: do $n exist in grep?
by LanX (Cardinal) on May 12, 2021 at 18:38 UTC
    or even easier

    DB<34> @a = qw/xxBxx yyAyy zzNzz/ DB<35> @N = map {/^..(A|B)./} @a DB<36> x @N 0 'B' 1 'A' DB<37>

    Hint: m// returns an empty list if there's no match

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2021-07-30 23:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?