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