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

    I thought about that when writing it. I decided that it didn't really matter as long as I was consistent. Though I do like the look of yours more than mine.

    I don't mind occasionally having to reinvent a wheel; I don't even mind using someone's reinvented wheel occasionally. But it helps a lot if it is symmetric, contains no fewer than ten sides, and has the axle centered. I do tire of trapezoidal wheels with offset axles. --Joseph Newcomer