David Corbin wrote:
>
> m:(?['<list>' => '</list>').*(?]):
>
> or more generically
>
> m:(?['<\w+>' => '</\1>').*(?]):
I think these are good; but I do also like the idea of "automatic
reversing" by default, since that's a common operation.
Let's combine the ideas, as Richard suggests. How about:
1. When a scalar value is provided as the argument
to ?[, then that value is automatically reversed
character-wise and bracket-wise.
2. When a list is provided, each pair in the list
is what to match.
So here are some examples:
m/(?[<<<)Some stuff(?])/; # <<<Some stuff>>>
m/\@(?[{[)weird perl(?])/; # @{[weird perl]}
m/(?['<\w+>' => '</\1>').*(?])/; # <tag>Text</tag>
# less verbose, more robust
my @tag = qw('<(\w+)\s*.*?>' => '</\1>');
m/(?[@tag)Some title(?])(?[@tag)Open(?[@tag)Embedded(?])(?]);
That last one would match
<h3>Some title</h3>
<div align="center">
Open
<b>Embedded</b>
</div>
So really, all RFC 145 needs to do is introduce ?[ and ?], which do a
couple things by default (like brace-matching and character reversing),
but are actually general-purpose nesting operators when provided with a
list of things to match.
-Nate