# File: rand1.pl # Title: Generate a random string over the alphabet of length N # Author: Mihaela Malita # Generates a random string over Alphabet = a c g t # Length of the string? 5 # Generated string is attac @Alphabet = ('a','c','g','t'); # declare array Alphabet print "Generates a random string over Alphabet= @Alphabet"; print "\nLength of the string? "; $n = ; chop($n); $s = ''; # initialize final S with empty '' foreach (1..$n){ $pos = int rand(4); # generates random integer position < 4 $s = $s . @Alphabet[$pos]; # concatenation with . } print "Generated string is $s"; exit;