in reply to Hangman Assistant
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() } }, $_; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Hangman Assistant
by Lawliet (Curate) on Jul 12, 2009 at 06:48 UTC |