ibm1620 has asked for the wisdom of the Perl Monks concerning the following question:
I need to extract substrings delimited by balanced parentheses, and I installed Regexp::Common to see what it could do. Here is a test program that embeds an example from the doc (https://metacpan.org/pod/Regexp::Common).
Unfortunately, it won't compile:#!/usr/bin/env perl use v5.36; use Regexp::Common; while (<>) { /$RE{num}{real}/ and print q{a number}; /$RE{quoted}/ and print q{a ['"`] quoted string}; m[$RE{delimited}{-delim=>'/'}] and print q{a /.../ sequence}; /$RE{balanced}{-parens=>'()'}/ and print q{balanced parentheses}; /$RE{profanity}/ and print q{a #*@%-ing word}; }
It seems that, at some point, it was permissible to write $foo{$bar, $frog}, which was understood by Perl to mean $foo{"$bar$;$frog"}, but this was later disabled (perl 5.33?). And I assume that {-delim=>'/'} is what's triggering the error, with '=>' being a fat comma.Multidimensional hash lookup is disabled at /Users/chap/private/perl/r +egcommon line 8, near "'/'}"
Is Regexp::Common out of date? None of the 28 open issues seems to address this condition. Is there a way to make it work under v5.36 and beyond? Is there a successor to Regexp::Common?
(Incidentally, it seems from searching for "perl multidimensional hash" that most people take this to mean simply chaining keys, a la $thing{$x}{$y}{$z}, which of course is alive and well, as opposed to forming a "composite key" as in $thing{$x, $y, $z}).
Update 1: replaced literals with variables in examples of multidimensional hash lookups, per jwkrahn's comment below.
|
|---|