if ($choice eq 'a'){ ... } #### if (CONDITION1) { ... } if (CONDITION2) { ... } #### if (CONDITION1) { ... if (CONDITION2) { ... } } #### if (CONDITION1) { ... } elsif (CONDITION2) { ... } elsif (CONDITION3) { ... } else { ... } #### $ perl -E 'my @x = qw{Jeff JEFF jEfF}; say lc $_ for @x' jeff jeff jeff #### $ perl -E 'my @x = qw{Jeff JEFF jEfF}; say ucfirst lc $_ for @x' Jeff Jeff Jeff #### $ perl -E 'my @x = qw{Jeff JEFF jEfF}; say ucfirst $_ for @x' Jeff JEFF JEfF #### #!/usr/bin/env perl use strict; use warnings; { my %father_of = get_son_to_father_map(); display_menu(); while (1) { my $menu_selection = get_menu_selection(); if ($menu_selection eq 'e') { print "Exiting ...\n"; last; } elsif ($menu_selection eq 'a') { print "Son-father pair addition.\n"; print "Enter son's name: "; chomp( my $son = ucfirst lc ); if (exists $father_of{$son}) { print "$father_of{$son} is the father of $son\n"; } else { print "Enter father's name: "; chomp( my $father = ucfirst lc ); $father_of{$son} = $father; } } else { print "Invalid menu selection! Try agin.\n"; } } print "Done!\n"; } sub display_menu { print <<'MENU'; Menu Selections =============== a - add son-father pair e - exit MENU return; } sub get_menu_selection { print "\nEnter menu selection: "; chomp( my $selection = lc ); return $selection; } sub get_son_to_father_map { return ( Jeff => 'Doug', Thomas => 'Evan', Robert => 'Jason', Bruce => 'Richard', Clark => 'Jon', ); } #### Menu Selections =============== a - add son-father pair e - exit Enter menu selection: qwerty Invalid menu selection! Try agin. Enter menu selection: Invalid menu selection! Try agin. Enter menu selection: a Son-father pair addition. Enter son's name: JEFF Doug is the father of Jeff Enter menu selection: a Son-father pair addition. Enter son's name: bRuCe Richard is the father of Bruce Enter menu selection: a Son-father pair addition. Enter son's name: fred Enter father's name: BILL Enter menu selection: a Son-father pair addition. Enter son's name: FrEd Bill is the father of Fred Enter menu selection: e Exiting ... Done!