while (<WORD>) { chomp; next if /[^a-z]/; # Lazy way out~ my @chars = split(//, $_); push @{$wordlist{$#chars}}, $_; }
You appear to have an off-by-one error where @chars contains the characters from the word in $_ so $#chars will be one less than the number of characters in $_. Perhaps you meant:
while ( <WORD> ) { chomp; next if /[^a-z]/; # Lazy way out~ push @{ $wordlist{ length() } }, $_; }
In reply to Re: Hangman Assistant
by jwkrahn
in thread Hangman Assistant
by Lawliet
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |