in reply to building similarity matrix

This doesn't work:

my $obj = WordNet::Similarity::"$Measure"->new($wn);

A better solution is to put the entire package name in a variable:

my $measure_class = "WordNet::Similarity::whatever"; my $measure = $measure_class->new(); ... sub similarity { ... return $measure->getRelatedness($w1, $w2); }

Besides fixing the syntax error, this will also create the measure object only once at the beginning of your script.

Also, note that using @words = <FILE> will leave the end of line characters on your strings, but maybe that's not a problem. If it is, just chomp your words:

chomp(@words = <FILE>);