First, your join statement on @br is useless as @br only contains one element.

Second, when you have a regex using a (?:...) modifier, anything between the question mark and colon acts as a local switch unless it's after a -, in which case, it serves to negate a switch that's been applied to the entire regex. In this case, the /x switch (or modifier, if you prefer) at the end of the regex has the regex ignore unescaped whitespace, which you don't have in your first regex. As a result, your /x switch serves no purpose in this regex, and would be negated by the ?-x: construct, in any event.

The reason why the second regex does not match is because it's trying to match "#commenthere" (note the lack of spaces). Since they don't appear in your target text, you get no match.

Hope this helps.

Cheers,
Ovid

Update: I'm a moron. I need to think about this one a bit more. It's a lot trickier than I first thought. Now that I have a better idea of what you are doing, this does look like a bug. Changing ?-x: to ?: makes it work, but (?-x:...) is supposed to be local.

P.S. I am using 5.005 (ActiveState on WinNT)


In reply to (Ovid) Re: codem/(?:-x pattern) #comment /x bug?/code by Ovid
in thread codem/(?:-x pattern) #comment /x bug?/code by dcorbin

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.