in reply to printing hash values and keys from user

You get this error because $type has a trailing newline character, which means that $type does not match any of your hash keys. You should chomp your input:
my $type = <stdin>; chomp $type;

See Basic debugging checklist Tip #3.

Update: I was surprised to see that lowercase stdin works just like uppercase STDIN. All the docs seem to just use uppercase for this special filehandle. Can some monk show me where this is documented?

Replies are listed 'Best First'.
Re^2: printing hash values and keys from user (OT: stdin vs. STDIN)
by AnomalousMonk (Archbishop) on Nov 02, 2010 at 02:27 UTC

    See I/O Operators in perlop, about the ninth paragraph:

    The filehandles STDIN, STDOUT, and STDERR are predefined. (The filehandles "stdin", "stdout", and "stderr" will also work except in packages ...)
      ++AnomalousMonk. It is probably a good practice to just stick with the uppercase version, to avoid different behavior in and out of packages.
Re^2: printing hash values and keys from user (OT: stdin vs. STDIN)
by pinnacle (Acolyte) on Nov 01, 2010 at 18:46 UTC

    Thanks All