sub count { my( $length, $alphabet )= @_; my @alphabet= split //, $alphabet; my @digit= (0) x $length; my $seq= $alphabet[0] x $length; while( 1 ) { print $seq,$/; my $pos= 0; while( @alphabet <= ++$digit[$pos] ) { substr( $seq, $pos, 1 )= $alphabet[ $digit[$pos]= 0 ]; return if $length <= ++$pos; } substr( $seq, $pos, 1 )= $alphabet[ $digit[$pos] ]; } } count( @ARGV ); # count( $_, "ACGT" ) for 8..10;