- or download this
my %word;
open my $fh, "<", "/usr/dict/words";
chomp, push @{$word{substr $_, 0, 1}}, $_ while <$fh>;
close $fh;
- or download this
if(grep $_ eq $user_input, @{$word{substr $user_input, 0, 1} || []}) {
# it's there
}
else {
# no, that wasn't it
}
- or download this
chomp, $_ = lc, push @{$word{substr($_, 0, 1)}}, $_ while <$fh>;
# and
grep lc eq $user_input, @{$word{substr($user_input, 0, 1)} || []}