I am trying to come up with an answer (for my own edification) for someone's homework, but I am getting a panic from perl in the regex I am starting to develop.

My idea was to use (?{...code}) constructs in the regex to count each occurence of 'ab' in the string, and when the end of the string was encountered, do 'something' that made the regex match if the count was odd, and fail if the count was even. I haven' quite divined what that 'something' is yet, as my perl 5.8.2 on RH Linux 7.2 is doing a

panic: top_env
when I try using the example from perlre

#!/usr/bin/perl -w use strict; my $cnt; my $res; my $regex = qr/ (?{ $cnt = 0 }) # Initialize $cnt. (?: # group only a (?{ local $cnt = $cnt + 1; # Update $cnt, backtracking-safe. }) )* aaaa (?{ $res = $cnt }) # success-copy to non-local var /x; foreach my $line (<DATA>) { chomp $line; print STDERR "huzzah |$`| |$&| |$'| $res $line\n" if $line =~ $re +gex; } __DATA__ aaaaaaaa aaaa

I've tracked it down to the  (?{local $cnt = $cnt + 1;}) part of the regex - remove that and the panic goes away.

I know the perlre says that (?{...code..}) is
WARNING: This extended regular expression feature is considered highly experimental, and may be changed or deleted without notice.
but I take that to mean experimental from a syntactic and semantic aspect, not nonoperational.

How does one begin to debug such an error ??

+++++++++++++++++
#!/usr/bin/perl
use warnings;use strict;use brain;


In reply to (?{...code..}) regex construct causing panic: top_env in 5.8.2 by leriksen

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.