Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Compared to the one I posted in 1996 []. Maybe I'm just missing something.
    • Randal L. Schwartz
    • Stonehenge
  • Neat. I've always been interested in weighted probabilities.

    I have a system I've used for lots of things where you select from a list where items near the top are more heavily weighted than items near the bottom. After selection, the selected item goes to the bottom of the list for the next round, meaning items that have not been recently selected are more likely to be picked sooner. Basically it's a way of randomly shuffling but giving precedence to trying not to repeat things too soon.

    This started

    J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
  • It would have been easier to follow what’s going on if you have edited the code prior to writing, so as to highlight what you are talking about. I might have written the first program like this:

    use Data::Dumper;
    use Math::Random::MT qw(rand);

    sub min_idx {
        my $idx = 0;
        for my $i ( 1 .. $#_ ) {
            $idx = $_[$idx] > $_[$i] ? $i : $idx;
        return $idx;

    sub run {
        my ( $arg ) = @_;
        my @n;