in reply to Re: finding { and }
in thread finding { and }

Or if you still insist on doing it yourself, you might want to use Text::Balanced which does exactly what you need in ways you probably haven't even thought of yet. Or even Parse::RecDescent if you can handle it, but in that case you're probably getting so close to doing your compiler's work that you really should hand the files over to it instead.