Hi,

I have a switch statement containing 10 different cases. in 5 of the cases, I 
need to set a variable to a certain value.

The ways I could think about are:

- setting the variable within each case statement, e.g.

case 'slurp' {
    $parameters{type} = 'gallery';
    ...
    }
    
- use a self defined subroutine "contained" to set the variable if 
$parameters{mode} is contained in the list of appropriate cases:

my @cases = ('slurp', 'list_pos', 'beschriftung' ...);
if (contained($parameters{mode}, @cases)) {
    $parameters{type} = 'gallery';
}

In example 1, I have to set the variable explicitly 5 times, in example 2, I 
have to manually list all cases outside the switch statement, which bears the 
risk of forgetting to modify the line once I extend the switch statement.

So is there a better way to do it?

Thanks,

Jan
-- 
There are 10 kinds of people:  those who understand binary, and those who don't

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to