Pedro Picasso has asked for the wisdom of the Perl Monks concerning the following question:

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