in reply to why does

btrott nailed the problem, but let me add that from your snippet it seems that you didn't know about the values function.

BTW browsing perlman:perlfunc:categorical is very worthwhile for learning about these nice built-in functions. It won't match exactly what you have installed, for that you will need to copy the table that you will find in perldoc perlfunc.