Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Complex if/else or case logic

by BrowserUk (Pope)
on Mar 17, 2014 at 20:56 UTC ( #1078685=note: print w/ replies, xml ) Need Help??


in reply to Complex if/else or case logic

If it is all constants:

my %actions = ( 'sender a' => { 'some text' => { 'some other text' => 'type 1', 'some other other text' => 'type 2', }, 'some other subject' => { ... }, }, 'sender b' => { ... }, ); sub action { my( $sender, $subject, $body ) = @_; my $rv = $action{$sender} // return 'unknown sender'; $rv = $rv->{$subject} // return 'unknown subject'; $rv = $rv->{$body} // return 'unknown body'; return $rv; }

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re: Complex if/else or case logic
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1078685]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2015-07-31 22:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (282 votes), past polls