I've got this GUI encyclopedia builder thing in Tk, and it's mega-cool, but when I run it on Apple's OS X, one of the regular expressions segfaults my application. Is this a problem with the Apple port of Perl? I run this under 5.6.0 and 5.8.0 and get a segmentation fault on each. Is my expression flawed?

Below I'm posting the code that crashes. It's a huge string fed into a relatively large expression. The string has to be sufficiently long and include something enclosed in square braces to cause a problem. Sorry if this looks ugly:

$text = "\n Prefetching [sets] WebObjects to fetch a related set o +f EOs when fetching a specified set of EOs. This can create fewer fe +tches and free up database time for other applications.\n For instan +ce, let's say that you have an Organization EO that had several Offic +e EOs that each had an Address EO. Now let's say that you had a comp +onent which listed all of the Offices and Office Addresses for a spec +ific Organization. Usually, you would fetch the Offices for an Organ +ization and each repeating table row would try to fault each and ever +y \"address\" relationship in each Office. That creates a fetch for +each relationship fault, and a lot of round trips to the database whi +ch use a lot of resources and makes your thing slow.\n The solu +tion is to tell WebObjects that after you fetch the Offices (using a +single fetch), you would like to fetch all of their addresses (using +another single fetch). This can be done with prefetching. Here we g +o:\n\n EOFetchSpecification spec = ...;\n String keypaths +() = {\"offices\", \"offices.address\"}; // \"offices\" is a relation +ship in Organization, and \"address\" is a relationship in Office.\n + spec.setPrefetchingRelationshipKeyPaths(new NSArray(keypaths));" +; if ($text =~ /^ ( # Any amount of: ( \[ # An open brace .*? # Any amount of non-brace stuff \] # A close brace ) | # Or [^\[] # Anything that's not an open brac +e. )* \] # Followed by a close brace /xs ) { print "The article contains a closing brace \"]\" with no opening br +ace."; } else {print "Okay, joe.";}

Thanks a bunch for looking at this. I'm going to be posting some cool Tk examples from my project in the coming weeks.

-the Pedro Picasso
(sourceCode == freeSpeech)

Edit by dws to clean up formatting


In reply to OS X vs. My Regex by Pedro Picasso

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.