package AnyLanguage; sub new { my $self = shift; my $self -> { LEXICON } = shift; return bless $self; } sub dispatch{ # match down array and react accordingly my $self = shift; $_ = shift; my $aref = $self -> { LEXICON }; for ( my $i = 0; $i < $#$aref; $i++ ) { my $regexp = $aref -> [$i] -> { REGEXP }; /$regexp/ and return &($aref -> [$i] -> { ACTION }}; } return &{$aref -> [$#$aref ] -> { ACTION }}; } 1;