AlexP has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks!
I wonder if there is another way to get named captured groups than %+ or %-.
Something like:
%nc = $str =~ /?<status>[\w\040]*)/; say %nc{status};
I'm trying to rewrite my code without globals like %+, %-, because I need to pass this hash to a sub and now it looks:
Maybe you know related modules or other solutions.my %matches = %+; sub(\%matches);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is there another way to get named captures
by LanX (Saint) on Jan 08, 2022 at 20:40 UTC | |
by AlexP (Pilgrim) on Jan 09, 2022 at 11:34 UTC | |
|
Re: Is there another way to get named captures
by Fletch (Bishop) on Jan 08, 2022 at 21:06 UTC | |
by LanX (Saint) on Jan 08, 2022 at 21:53 UTC | |
by Fletch (Bishop) on Jan 09, 2022 at 04:46 UTC | |
by AlexP (Pilgrim) on Jan 09, 2022 at 11:39 UTC | |
|
Re: Is there another way to get named captures
by AlexP (Pilgrim) on Jan 10, 2022 at 13:22 UTC | |
by Corion (Patriarch) on Jan 10, 2022 at 13:31 UTC | |
by AlexP (Pilgrim) on Jan 11, 2022 at 12:47 UTC | |
by AlexP (Pilgrim) on Jan 10, 2022 at 19:12 UTC |