<?xml version="1.0" encoding="windows-1252"?>
<node id="1016030" title="Dynamically inspecting Regex OP-Codes at runtime?" created="2013-01-30 06:04:31" updated="2013-01-30 06:04:31">
<type id="115">
perlquestion</type>
<author id="708738">
LanX</author>
<data>
<field name="doctext">
Hi&lt;P&gt;&lt;P&gt;

ATM I need plenty of hacks to be able to dynamically see the OP-Tree of a Regex at runtime cause
&lt;c&gt;use re 'debug'&lt;/c&gt; emits the code of a regex at &lt;b&gt;compile time&lt;/b&gt; to &lt;b&gt;STDERR&lt;/b&gt;.&lt;P&gt;&lt;P&gt;

&lt;c&gt;
lanx@nc10-ubuntu:~$ perl
use re 'debug';
my $a=qr/(?&lt;C&gt;1)(?&lt;D&gt;2)(3)(?&lt;A&gt;4)/;
Compiling REx "(?&lt;C&gt;1)(?&lt;D&gt;2)(3)(?&lt;A&gt;4)"
Final program:
   1: OPEN1 'C' (3)
   3:   EXACT &lt;1&gt; (5)
   5: CLOSE1 'C' (7)
   7: OPEN2 'D' (9)
   9:   EXACT &lt;2&gt; (11)
  11: CLOSE2 'D' (13)
  13: OPEN3 (15)
  15:   EXACT &lt;3&gt; (17)
  17: CLOSE3 (19)
  19: OPEN4 'A' (21)
  21:   EXACT &lt;4&gt; (23)
  23: CLOSE4 'A' (25)
  25: END (0)
anchored "1234" at 0 (checking anchored) minlen 4 
Freeing REx: "(?&lt;C&gt;1)(?&lt;D&gt;2)(3)(?&lt;A&gt;4)"
&lt;/c&gt;&lt;P&gt;&lt;P&gt;

In [id://1016024] I need to recompile a new regex within an eval while redirecting STDERR to a variable...&lt;P&gt;&lt;P&gt;

Thats hacky and cumbersome!&lt;P&gt;&lt;P&gt;

Is there any simpler or cleaner way to achieve this?&lt;P&gt;&lt;P&gt;

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-708738"&gt;
&lt;p&gt;Cheers Rolf
&lt;/div&gt;&lt;/div&gt;</field>
</data>
</node>
