#!perl -w @nums = 100000 .. 999999; # Generate all the possible numbers ## Shuffle them (use a better rand if needed) $_ ne ($a=int( rand( $#nums-$_+1))+$_) and $nums[$_] ^= $nums[$a] ^= $nums[$_] ^= $nums[$a] for (0..$#nums); print pop@nums; # pop a new one each time you need it