in reply to capture value from two patterns
that's IMHO the shortest and most intuitive
DB<35> $_='a' DB<36> ; /(a)/ or /(b)/; $x= $1 DB<37> p $x a DB<38> $_='b' DB<39> ; /(a)/ or /(b)/; $x= $1 DB<40> p $x b DB<41>
I'm aware you wanted the list assignment approach, but it's longer because you'd need to repeat ($x) = for each term and I prefer DRY idioms.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: capture value from two patterns (updated)
by AnomalousMonk (Archbishop) on Aug 20, 2020 at 22:31 UTC | |
by LanX (Saint) on Aug 20, 2020 at 23:37 UTC |