I was playing around with this and noticed a harmless but problematic side-effect of the way you construct the hash.
%scores = ( map { $_ => 1 } qw( A E I L N O R S T U ), map { $_ => 2 } qw( B D G ), map { $_ => 3 } qw( C M P ), map { $_ => 4 } qw( F H V W Y ), map { $_ => 5 } qw( K ), map { $_ => 8 } qw( J X ), map { $_ => 10 } qw( Q Z ), ); print join($", sort keys %scores), $/; __END__ 10 2 3 4 5 8 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Since you're filtering for letters, the numbers don't get picked up, but the maps are having a side-effect mapping of the other maps below them. Parens around the maps seems to fix it.
I also learned something from your example. I would have predicted that the last unless defined would not work right on empty input b/c $_ still contains a "\n" which would be defined. I would have been wrong.
In reply to Re^2: Homework help
by Your Mother
in thread Homework help
by gitarwmn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |