#!/usr/bin/env perl use strict; use warnings; my %ex = ( 37 => 'p', 41 => 't', 23 => 's', 52 => 'm', 44 => 'a', 65 => 'q', 26 => 'd', 88 => 'o', 99 => 'g', 100 => 'l', 101 => 'f', 201 => 'i' ); print 'Enter the key you want to search for: '; my $k = <>; chomp $k; if (exists $ex{$k}) { print "The key '$k' has the value: $ex{$k}\n"; } else { print "The key '$k' doesn't exist.\n"; }