in reply to Finding similar data

I'm sure there's a module on CPAN.

But if your query is as simple as only sorting to first 3 letters, then the following may do the trick:

my @words = qw(sem sema cat semok hgt cato seme cate); my %similar = (); foreach my $word ( @words ) { push( @{$similar{substr($word,0,3)}}, $word ); } foreach my $prefix ( sort keys %similar ) { print( join( ', ', @{$similar{$prefix}} ) ); print( "\n" ); }
prints:
cat, cato, cate hgt sem, sema, semok, seme