in reply to Simple IF, IF, IF or ELSE
Alternative:if ($punter eq 'coffee') { $drink = 'non alky'; } elsif ($punter eq 'beer' ) { $drink = 'alky'; } elsif ($punter eq 'whisky') { $drink = 'proper alky'; } else { $drink = 'unknown'; }
my %lookup = ( 'coffee' => 'non alky', 'beer' => 'alky', 'whisky' => 'proper alky', ); if (exists $lookup{$punter}) { $drink = $lookup{$punter}; } else { $drink = 'unknown'; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Simple IF, IF, IF or ELSE
by dsheroh (Monsignor) on Jun 28, 2006 at 22:02 UTC |