in reply to Phone Book
$userInput = <STDIN>; chomp $userInput; $userInput = uc $userInput; # you could probably do this on the STDIN, but I am not sure. # Another monk should be able to tell you. ( $userInput eq 'L' or $userInput eq 'LIST' ) ? list_phone_book() : ( $userInput eq 'A' or $userInput eq 'ADD' ) ? add_to_phone_book +() : ( $userInput eq 'D' or $userInput eq 'DELETE') ? delete_from_phone +_book() : ( $userInput eq 'Q' or $userInput eq 'QUIT' ) ? quit_phone_book() : unknown_selection +();
As it stands now, you would have read your whole script line by line to figure out where you are going for your selections. With the above code, you know where to look for each selection and what it is supposed to do.
You are also doing a bunch of open and closes all over the place, I beat your could get rid of a bunch of code by breaking those down in subroutines.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Phone Book
by Lawliet (Curate) on Jan 04, 2009 at 20:02 UTC |