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 (Saint) 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