This totally made my day - the efficiency. In an extension of the original requirement, I needed to generate long fixed length strings from random elements in an array.. this is so much faster than what I was using.. I've no absolute requirement for total uniqueness, but it looks like no letter is being repeated in multiple runs of:push @num, splice(@array, int rand @array, 1);
-hsinclai#!/usr/bin/perl -w use strict; my $counter = "0"; my $randstring; my @testarray = ( 'a' .. 'z', 'A' .. 'Z', '0' .. '9' ); do { $randstring .= splice(@testarray, int rand @testarray,1); ++$counter; } until $counter == 62; print "\n\$randstring: $randstring\n\n";
In reply to Re: Re: Select three random numbers between 1..10
by hsinclai
in thread Select three random numbers between 1..10
by Perl_User
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |