Can I use Perl regular expressions to match balanced text?

No, regular expressions just aren't powerful enough. Perl regular expressions aren't strictly ``regular'', mathematically speaking, because they feature conveniences like backreferences (\1 and its ilk). But they are not the proper tool for every nail. You still need to use non-regex techniques to parse balanced text, such as the text enclosed between matching parentheses or braces, for example.

An elaborate subroutine (for 7-bit ASCII only) to pull out balanced and possibly nested single chars, like ` and ', { and }, or ( and ) can be found in CPAN/authors/id/TOMC/scripts/pull_quotes.gz .

The C::Scan module from CPAN also contains such subs for internal usage, but they are undocumented.