G'day perlancar,

Noting the "use 5.020000;" in your code, and the versions you used for testing, I attempted to replicate your results using a variety of versions. Unfortunately, other than "use 5.020000;" correctly barring a 5.18.0 test, pretty much everything else blew up in my face.

My CSelTest.pm is a [download] copy of your posted code. I ran the tests like this:

$ perl -MCSelTest -MData::Dump -E 'dd CSelTest::parse(q{ [attr] })'

Here's the results:

v5.18.0 : darwin-thread-multi-2level

Successfully tested: use VERSION

Perl v5.20.0 required--this is only v5.18.0, stopped at CSelTest.pm li +ne 3. BEGIN failed--compilation aborted at CSelTest.pm line 3. Compilation failed in require. BEGIN failed--compilation aborted.
v5.20.0 : darwin-thread-multi-2level
v5.20.2 : darwin-thread-multi-2level

Both tests unsuccessful. Result: PANIC!

panic: memory wrap at CSelTest.pm line 107. Compilation failed in require. BEGIN failed--compilation aborted.
v5.22.0 : darwin-thread-multi-2level
v5.24.0 : darwin-thread-multi-2level

Both tests unsuccessful. Result: FATAL!

Switch (?(condition)... not terminated in regex; marked by <-- HERE in + m/ (?&ATTR_SELECTOR) (?{ $_ = $^R->[1] }) (?(DEFINE) ... ) # DEFINE <-- HERE / at CSelTest.pm line 107. Compilation failed in require. BEGIN failed--compilation aborted.

I suspect some sort of copy/paste error; please address.

Here's another possible copy/paste error:

% perl -I. -Ilib -MCSelTest -MData::Dump -E'dd( CSelTest::parse_csel(q +{ [attr=1] }) )' [[{ name => "attr" }], "eq", 1]

That's the same output as the next test with [attr eq 1]. For [attr=1], I would've expected '"="', rather than '"eq"', in the output; i.e.

% perl -I. -Ilib -MCSelTest -MData::Dump -E'dd( CSelTest::parse_csel(q +{ [attr=1] }) )' [[{ name => "attr" }], "=", 1]

— Ken


In reply to Re: Weirdness (duplicated data) while building result during parsing using regex by kcott
in thread Weirdness (duplicated data) while building result during parsing using regex by perlancar

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.