or alternatively, sort the items by $somehash ||= -M item into the array and just shift off the first three before doing the rand().# ... my @not_recent = grep !defined( $recent_ids{ $_ } ), @ids; my $idno; { use integer; $idno = (1+$#not_recent) * rand(); } # ...
-M
Free your mind
In reply to Re: Don't-Repeat-Myself code for improvement
by Moron
in thread Don't-Repeat-Myself code for improvement
by Cody Pendant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |