No need to loop. Set up the list with the appropriate numbers of 1s and 0s and then shuffle it.
use List::Util qw[shuffle]; $m = 65; $n = 100; @list = ( (1) x $m, (0) x ( $n - $m ) ); @list = shuffle @list;
In reply to Re: random elements with fixed totals
by BrowserUk
in thread random elements with fixed totals
by ysth
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |