in reply to something like switch(case) in Perl
However, your code looks like you could use a loop and some kind of data structure.
If the person in %House is found, the print and function call will be executed, and we'll continue with the next key in the loop. Otherwise, we exhaust the possibilities of the table and fall through to the bottom of the inner loop.my @Data = ( {person => "CC", who => "My name ", func => \&p_CC }, {person => "AB", who => "AB ", func => \&p_AB }, {person => "CD", who => "friend", func => \&p_CD }, ); PERSON: foreach $person ( keys %house ) { foreach ( @Data ) { if ( $_->{ person } eq $person ) { print $_->{ who }; &{ $_ }->{ func }(); next PERSON; } } # Handle else here. }
And I would put the most likely array elements near the top (if possible) in order to reduce the execution time.
That's it!
--t. alex
"Of course, you realize that this means war." -- Bugs Bunny.
|
|---|