#! /usr/bin/perl use strict; my %son_father; my $choice; my $name1; my $add_dad; %son_father = (Jeff => "Doug", Thomas => "Evan", Robert => "Jason", Bruce => "Richard", Clark => "Jon") ; my $menu = <); # fulfill the user request if ($choice eq 'a'){ print "Enter a male name: "; chomp ($name1 = ); if (exists $son_father{$name1}) { print "Duplicate name -- try again!\n"; next; } print "Add a father: "; chomp ($add_dad = ); $son_father{$name1} = $add_dad; print "Added\n"; next; # <<<<< added } if ($choice eq 'd') { print "Enter a male name: "; chomp ($name1 = ); if (exists $son_father{$name1}) { delete $son_father{$name1}; print "Deleted.\n"; } else { print "Sorry, couldn't find '$name1' -- try again later!"; } next; } if ($choice eq 'o') { print "$_\t=> $son_father{$_}\n" for sort keys %son_father; next; } if ($choice eq 'e') { print "Come back again -- goodbye!"; exit; }else { print "Invalid choice, TRY AGAIN!\n"; } }