http://www.perlmonks.org?node_id=151571

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

#Answering How to find matching pairs ran into what appears to be a regexp bug
#Changing /geo to /ge Caused a core dump with v5.6.0
#but I couldn't replicate the core dump on v5.6.1 for IP32-irix
#v5.6.1 still has a problem though,
# C(D()) is not not expanded in this example
# Could someone verify this bug on their version of perl?
#
use strict; # example 2 my $text = doFunc( "MAIN", "A(B(2)+C(D()))" ); print "Example 2: $text\n"; sub doFunc { my( $theFunc, $theParam ,$re) = @_; {no warnings "uninitialized"; ($re=$theParam)=~s/((\()|(\))|.)/${[')']}[!$3]\Q$1\E${['(']}[!$2]/g +s; } $re= join'|',map{quotemeta}eval{$theParam=~/$re/}; die $@ if $@=~/unmatched/; #$re = qr/$re/; print "$theFunc: '$theParam' =~ /$re/\n"; print join"\n",$theParam=~/([A-Z]+)\(($re)\)/g,"\n"; $theParam =~ s/([A-Z]+)\(($re)\)/&doFunc($1,$2)/ge; return "func $theFunc returns <$theParam>"; } #returns #Example 2: func MAIN returns <func A returns <func B returns <2>+C(D( +))>> #should return #Example 2: func MAIN returns <func A returns <func B returns <2>+func + C ret\urns <func D returns <>>>> #