in reply to Re: Phone Book
in thread Phone Book
$userInput = <STDIN>; chomp $userInput; $userInput = uc $userInput;
can be written (more concisely) as
chomp(my $userInput = uc <STDIN>);Also, I think there may be a better method to running each subroutine than using multiple conditional operators. Perhaps a dispatch table will do.
my %pbactions = ( L => \&list_phone_book, LIST => \&list_phone_book, A => \&add_phone_book, ... ); # Later on~ defined $pbactions{$userInput} ? $pbactions{$userInput}->() : usage();
Untested lines of code, they're just to inspire.
And you didn't even know bears could type.
|
|---|