sub combinationN { my ($O,$Z,$current,$tL) = @_; my $string = ''; my $ff = 1; my $Dc = 0; my $Oc = int($current % $O); ## my $Zc = int($current % $Z); ## my $place = 1; while ($tL > $place) { if ($ff eq 1) { $Dc = $O-$Oc; for (1..$Dc) {$string .= '1'} $Oc = $Dc; } else { $Dc = $Z-$Zc; for (1..$Dc) {$string .= '0'} $Zc = $Dc; } $place += $Dc; $ff *= -1; } print "$string\n"; return $string }