Help for this page

Select Code to Download


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