#!/usr/bin/perl my $family, $x=0, $i=0, $v=0, $one=1, $g, $xx, $del=0, $del_rec, $slot=0; my %phonebook, $var, $choice, $sub_choice, $file_rec=0; @array=qw(Firstname: Lastname: Phone: City: Province/State: Postal/Zip: Country:); @menu=("1. Add an entry", "2. Search for an entry", "3. Remove an entry", "4. Exit"); @num=qw(1 2 3 4 5 6 7); my $string; open(FILER, "phone.txt") or die("Can not open file"); @file=; foreach (@file) { chomp($phonebook{$array[$x]}[$slot]=$file[$i]); ++$x; while ($x==7){ ++$v; ++$slot; $x=0;} ++$i; } close (FILER); until ($choice==4) { for ($x=0;$x<4;++$x){ print("\t\t$menu[$x]\n"); } if($del!=1){ chomp($choice=);} if ($choice==1) { for $i(0 .. 6){ print ("$array[$i]\n"); foreach $family($array){ chomp($phonebook{$array[$i]}[$v]=);} } $v++; } elsif($choice==2) { print("There are " .$v+$one. " user(s) added to the phonebook.\n"); for $i(1 .. 7) {print("$i. $array[$i-1]\n"); } chomp ($sub_choice=); print ("Enter Search Variable\n"); chomp ($string=); $xx=1; for $i(0 .. 6) { if ($sub_choice==$num[$i]) { for (my $p=0; $p<$v; $p++) { if ($phonebook{$array[$i]}[$p]=~m/$string/) { $xx=2; print("User Record: $p\n"); for $g(0 .. 6){ print ("\t\t\t\t\t$phonebook{$array[$g]}[$p]\n"); ++$g; } print("\n\n"); } } } } if ($xx==1) { print("No Record of that user found\n\n");} if ($del==1) { print("Delete Record #:\n"); chomp($del_rec=); for$g(0 .. 6) { delete $phonebook{$array[$g]}[$del_rec]; } $del=0; }} } elsif($choice==3) { $choice=2; $del=1; } } open(FILEW, ">phone.txt") or die("Can not open file"); for $x(0 .. ($v-1)) { for $i(0 .. 6) { print FILEW "$phonebook{$array[$i]}[$x]\n"; } } close(FILEW);