Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Poker module question

by jwkrahn (Monsignor)
on Jul 14, 2012 at 04:27 UTC ( #981760=note: print w/ replies, xml ) Need Help??


in reply to Poker module question

sub ScoreHand { # returns the score of the passed in @hand or ShortHan +d my @hand = @_; return(7462) unless(@hand == 1 || @hand == 5); my $sh +rt; my $aflg = 0; $aflg = 1 if(ref($hand[0]) eq 'ARRAY'); my $aref; if( $aflg ) { $aref = $hand[0]; } else { $aref = \@hand; } if(@{$aref} == 1) { $shrt = $aref->[0]; } else { $shrt = ShortHand($aref); } if( $slow ) { return(SlowScoreHand($shrt)); } else { return( $zdnh{$shrt}); } }

IMHO that would look better as:

sub ScoreHand { # returns the score of the passed in @hand or ShortHan +d return 7462 unless @_ == 1 || @_ == 5; my @hand = @_; my $aref = ref $hand[ 0 ] eq 'ARRAY' ? $hand[ 0 ] : \@hand; my $shrt = @$aref == 1 ? $aref->[ 0 ] : ShortHand( $aref ); return $slow ? SlowScoreHand( $shrt ) : $zdnh{ $shrt }; }


Comment on Re: Poker module question
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2015-07-02 00:19 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 (25 votes), past polls