It always sets $x to 'fail' for me, probably because I do not populate the hash. You should show a complete code example that any of us can run: how you call your sub, how you know if it passes or fails, how you initialize your hash. Also, tell us what you enter on the keyboard once you run it.