Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: Lady Aleena's first working module

by Herkum (Parson)
on Oct 07, 2009 at 14:34 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-19 20:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found