Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^2: Lady Aleena's first working module

by Herkum (Parson)
on Oct 07, 2009 at 14:34 UTC ( #799734=note: print w/replies, xml ) Need Help??

in reply to Re: Lady Aleena's first working module
in thread Lady Aleena's first working module

Now you are doing one of my pet peeves, using to much syntax which is not clarifying the code at all. This is better,

my $type = shift; return $type eq 'parts' ? $parts[ rand @parts] : $type eq 'good_vs_evil' ? $good_vs_evil[ rand @good_v +s_eval] : $type eq 'lawful_vs_chaotic' ? $lawful_vs_chaotic[ rand @lawful +_vs_chaotic] ? q{}

Replies are listed 'Best First'.
Re^3: Lady Aleena's first working module
by Tux (Canon) on Oct 07, 2009 at 18:46 UTC

    That kind of code will only work of there is just one return, and "" (or the hideous q{} from PBP) is the only possible alternative.
    My example just simplifies the pre-emptive returns, and lives in the assumption that the default (after all the returns were done) still needs some real coding.

    Personally, I like brevity, and both my code and yours are terse. I do not however think that your code is any clearer than mine. Both are clearer than the code of the OP though.

    Enjoy, Have FUN! H.Merijn

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2021-04-20 18:38 GMT
Find Nodes?
    Voting Booth?

    No recent polls found