"do" is not really a loop but if you use "until" or "while" with it you can get it to act like a loop. The problem with your code is that $start never has a chance to equal zero so the "do" block just keeps getting repeated over and over. Thix will help you see whats going on:
use warnings;
use strict;
my @list;
print "Enter number of OTUs:";
my $start = <STDIN>;
chomp $start;
do {
my $rand = int(rand($start));
print "rand = $rand\n";
push (@list, $rand);
$start-=$rand;
print "\$start = $start\n";
} until ($start == 0);
print "@list";
Reputation Points: 246
Solved Threads: 67
Practically a Posting Shark
Offline 898 posts
since Mar 2006