If I understand the documentation, you can remove eval from there, as it's useless for qr{}.

Well, as far as I can tell, the code the OP posted doesn't make use of the eval feature at all , the code section is a literal

literal

$ perl -E " $_ = 123; m/\d(?{ warn pos })/" 1 at (re_eval 5) line 1. $ perl -E " no re qw/eval/; $_ = 123; m/\d(?{ warn pos })/" 1 at (re_eval 5) line 1. $ perl -E " $_ = 123; $f = qr/\d(?{ warn pos })/; m/$f/;" 1 at (re_eval 5) line 1. $ perl -E " no re qw/eval/; $_ = 123; $f = qr/\d(?{ warn pos })/; m/$f +/;" 1 at (re_eval 5) line 1.

variable aka "dynamic" aka it throws error :)

$ perl -E " $_ = 123; $f = '(?{ warn pos })'; m/\d$f/; " Eval-group not allowed at runtime, use re 'eval' in regex m/\d(?{ warn + pos })/ at -e line 1. $ perl -E " $_ = 123; $f = '(?{ warn pos })'; $g = qr/\d$f/; m/$g/" Eval-group not allowed at runtime, use re 'eval' in regex m/\d(?{ warn + pos })/ at -e line 1.

I believe whatever the OPs real code, he got this error message so he added the "solution"

I also believe there is no need for any of this stuff :) if all the OP is doing is building a data structure, simply match in a loop and use %+ or use Regexp::Grammars


In reply to Re^2: Question on Regular Expression by Anonymous Monk
in thread Question on Regular Expression by sjain

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.