use strict; use warnings; my ($inp, $name, $address, %directory); print "Welcome to your own Personal Address Book!\n"; while (1) { while (1) { print " What would you like to do?\n ADD Add An Entry DEL Delete An Entry PRN Print All Entries END End Program\n\n"; $inp = uc getInput(''); last if $inp eq 'ADD' || $inp eq 'DEL' || $inp eq 'PRN'; exit if $inp eq 'END'; } print "\n"; if ($inp eq 'ADD') { $name = getInput('Enter a name to add'); $address = getInput('Enter the corresponding address'); $directory{$name} = $address; } elsif ($inp eq 'DEL') { $name = getInput('Enter a name to remove'); delete $directory{$name}; } else { print "These are the people in your address book:\n\n"; print "$_\t\t$directory{$_}\n" for sort keys %directory; } } sub getInput { my $inp; while (1) { print "$_[0]: "; chomp($inp = ); return $inp if $inp; } }