Witch Hat?

Eight utterly altruistic and very clever gnomes are trapped in a cave with a wicked witch, and a lot of black and white hats. She would like to kill them all, but figures she might as well take her time. So she proposes the following entertaining game, which she describes to the gnomes. She's going to line them all up, one behind the next, facing the entrance of the cave. Then she'll "poof" out the lights, and place a hat, either black or white, on each gnome's head. The she'll "poof" the lights back on. Each gnome will be able to see the hats of the gnomes in front of himself, but not his own, and not the hats of the gnomes behind himself. Starting with the gnome at the back of the line, she'll ask what color hat he has on. He must answer her question out loud. If he answers correctly, he lives (although he can't make any sound other than to answer her question). If he answers incorrectly, he dies, completely silently. All gnomes that are alive at the end will be set free. The witch gives them a few happy minutes to ponder their fate. Instead of pondering the meaning of life, which doesn't seem terribly applicable at the moment, or the meaning of death, which is applicable but depressing, they instead devise a strategy. How many gnomes will escape?

ANSWER
SOLUTION in rhyme, by my Uncle Henry.