use strict; use warnings; my %words = ( 'hello' => 'world' ); print 'type a word: '; chomp( my $inData = <> ); print $words{$inData} // "Key '$inData' doesn't exist.\n";