in reply to Cleaner Regex

The easy fix is to just simply capture the closing bracket as well:

$ab=~s/ \{ \s* eval ([^\}]+ \}) \s* \} /$1/egx; # x modifier added for clarity

However, your code does have other problems. For instance, the inner blocks (the ones in which the eval is located) may contain other statements besides the eval. The eval-block may itself contain inner blocks as well as containing strings that contain brackets. As it stands, all of these cases will cause your regex to fail. Although you may be able to ignore many of them if you are working within a closed system (i.e., you are in control of the input), it seems that you at least need to worry about strings containing brackets. If you do in fact need to worry about parsing full code, then you may want to consider using a full parsing system like Parse::Recdescent.

For help in dealing with parsing arbitrary code, you can take a look at Parsing with Perl 6. Although the article deals with parsing code using Perl6 regular expressions, it also provides Perl5 equivalant code at the bottom which you can probably make use of.