for my $i (0 .. 5006) { ... } #### #!/bin/perl use strict; use warnings; my $thing = join '', map{qw(a t c g)[rand 4]} 1 .. 5007; my $fName = "./test"; open my $outFile, '>', $fName or die "Can't create '$fName': $!\n"; print $outFile $thing; close $outFile;