##
@total = (); #this is an array of arrays
@haplotypes=();
$currentPop = 0;
$sampleSize={}; # This will hold the sample size for each population
while() {
chomp;
if (/^(\-{0,1}\d+\t-{0,1}\d+)/) {
$sampleSize{$currentPop}++;
@temp = split;
push @{$haplotypes{$currentPop}}, [@temp];
} elsif (/segsites: (\d+)/) {
$currentPop++;
push @total, $currentPop;
}
}
foreach $_ (@total) {
for($i = 0; $i < $sampleSize{$currentPop}; $i++){
$Rand=rand(int(@{$haplotypes{$_}}));
$temp=splice (@{$haplotypes{$_}}, $Rand, 1);
push @{$RandHapl{$_}}, $temp;
}
}