$zero = 0; @names; while ($zero == 0) { print ("Enter a name or command: "); $text = readLine(); if ($text eq "exit") { exit(); } if ($text eq "view" && @names == 0) { print("There are no names in the phonebook.\n") } if ($text eq "view" && @names > 0) { print(@names); } if ($text ne "view" && $text ne "undo") { push(@names, "$text\n"); } if ($text eq "help") { print("\nThis little program allows us to create a list of names. So, just incase you forget names a lot, you can make a nice list of them to refer to. (Super nifty, huh?)\n Commands:\n View\t(lists the names you've created)\n Undo\t(will delete the most recently added name)\n Clear\t(will delete past 100 names)\n\n"); pop(@names); } if ($text eq "undo") { print(pop(@names)); print("... has been deleted!\n\n"); } $count = 100; if ($text eq "clear") { print("Are you sure?\n"); $answer = readLine(); if ($answer eq "yes") { while ($count > 0) { pop(@names); $count--; } print("Your list has been cleared.\n"); } } } sub readLine() { my ($output); $output = ; chomp($output); return($output); }