abachus has asked for the wisdom of the Perl Monks concerning the following question:
Hello once again !
Isaac.
The code below as you can see is a simple way to assign a value to $drink after $punter has been evaluated.
if($punter eq 'coffee'){ $drink = 'non alky'; } if($punter eq 'beer'){ $drink = 'alky'; } if($punter eq 'whisky'){ $drink = 'proper alky'; } else { $drink = 'unknown'; }
Now, surely there is a better way to do it, by that i mean with less lines of code, and if possible doing the same in a more efficient way.
I look forward to any answers, thanks,Isaac.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Simple IF, IF, IF or ELSE
by ikegami (Patriarch) on Jun 28, 2006 at 20:48 UTC | |
by dsheroh (Monsignor) on Jun 28, 2006 at 22:02 UTC | |
Re: Simple IF, IF, IF or ELSE
by GrandFather (Saint) on Jun 28, 2006 at 21:02 UTC | |
by abachus (Monk) on Jun 28, 2006 at 21:25 UTC | |
by GrandFather (Saint) on Jun 28, 2006 at 21:32 UTC | |
by abachus (Monk) on Jun 28, 2006 at 22:47 UTC | |
by GrandFather (Saint) on Jun 28, 2006 at 22:58 UTC | |
Re: Simple IF, IF, IF or ELSE
by VSarkiss (Monsignor) on Jun 28, 2006 at 20:58 UTC | |
by GrandFather (Saint) on Jun 28, 2006 at 21:16 UTC | |
Re: Simple IF, IF, IF or ELSE
by traveler (Parson) on Jun 28, 2006 at 21:49 UTC |
Back to
Seekers of Perl Wisdom