use strict; use Text::Soundex; my @inwords = qw(holly perl monks yahoo monk holey google eperl holy goxgle kugel april); my (%hash, @outwords); push @{$hash{soundex($_)}}, $_ foreach @inwords; push @outwords, @{$hash{$_}} foreach keys %hash; print join(' ', @outwords);