# File: tr1.pl # Author: Jason L. Bryant # Title: This program asks for an integer, makes a string of # that many characters with a set alphabet, and replaces letter a # OUTPUT: # Alphabet = a c g t # Enter an integer (length of string)? 5 # Generated String is acgaat # Modified String is cgt @Alpha = ('a','c','g','t'); print "Alphabet = @Alpha\n"; print "Enter an integer (length of string)? "; $N = ; $i = 0; # i for while $str = ''; # initialize final S with empty '' while ($i < $N ) { $i = $i + 1; $pos = int rand(4); # generates random integer < 4 $str = $str . $Alpha[$pos]; # concatenation with . } print "Generated string is $str\n"; $str =~ tr/a/ /; #replaces all a's with spaces print "Modified string is $str\n"; exit;