Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: short sorts

by Lady_Aleena (Deacon)
on Mar 30, 2012 at 17:23 UTC ( #962656=note: print w/ replies, xml ) Need Help??


in reply to Re: short sorts
in thread short sorts

Thank you for pointing that out to me. I changed the last lines of the subroutine to include tobyink's suggestion of croak above in Re: short sorts. So now I have a more explicit conditional just to keep things tidy. Thanks! :)

if ($type) { croak "$type is not supported" if !exists $sorts{$type}; return $sorts{$type}->($a,$b); } else { my $random_sort = (keys %sorts)[rand (keys %sorts)]; return $sorts{$random_sort}->($a,$b); }

Update

Since the random sort is not acting as I expected, I decided to just let the subroutine die there.

if ($type) { croak "$type is not supported" if !exists $sorts{$type}; return $sorts{$type}->($a,$b); } else { die "A sort type was not selected."; }
Have a cookie and a very nice day!
Lady Aleena


Comment on Re^2: short sorts
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (13)
As of 2015-07-02 09:01 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 (32 votes), past polls