ucf::Constit::ScopeConstit; ucf::Constit::NounCn; ucf::Constit::PrepCn; several other kinds of Prep ucf::Constit::VerbCn; ucf::Constit::ModifierCn; #### package base::ObjInheritance; use strict; use Carp; use Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(InheritsFrom); use List::Util qw(first); sub InheritsFrom{ my($ObjRef, $className) = @_; # I"ve scrubbed the error checking code for clarity my $oref = ref $ObjRef; &IF1($oref, $className)} sub IF1{ # $ref and $className will both be strings, which name classes. my($ref, $className) = @_; return 1 if $ref eq $className; # We've found an inheritance! my $isa = '@' . $ref . '::ISA'; # Rely on the ref being the package my @parents = eval $isa; # Find the @ISA for the package and eval it foreach my $heather (@parents){ # Recurse on the parents next if $heather eq 'Exporter'; if(&IF1($heather, $className)){ return 1}}; 0} # Found no inheritance in this branch. #### my $NPs = [grep &InheritsFrom($_, 'ucf::Constit::NounCn'), @$sentence]