指定长度,生成一个随机的DNA序列



use strict;
use warnings;


            #进行定义
my @dna;
my $dna_length;
my $newbase;
my $i=0;

print "please input the DNA length\n";
chomp($dna_length=<>);

while($i<$dna_length)
{

           #从四个碱基中随机选取一个
	my(@nucleotides)=qw/A T G C/;
	$newbase=$nucleotides[rand @nucleotides];

          #将随机生成的序列添加到@dna的数组中
  push(@dna,$newbase);
	++$i;
}
print "@dna";



你可能感兴趣的:(input,Warnings)