in reply to Matching Perl Keywords

You might also want to look at the source of the Text::Balanced module. You may be able to adapt it to your needs.

The source code of Filter::Simple would also be instructive, since it has to provide a similar "ignore the stuff in quotelikes" functionality. I guess it's no surprise that it uses Text::Balanced to do that.