in reply to Finding C++ single inheritance occurrances

That code doesn't work at all: it returns the entire $string if it matches the expression, or nothing otherwise. Also, the expression captures the word "class" or "struct", which is pretty useless. You were on the right track with your pseudocode, and probably want to do something along these lines:
%stuff = ($text =~ /(?:class|struct) \s+ ([\w\d_:]+) \s* : \s* (?:public|protected|private) \s+ ([\w\d_:]+) \s* \{/gsx);
Then keys %stuff would be the class names, with $stuff{CLASS} being CLASS's parent.