lenti264 [~/perltest]>more arrays2.pl #!/user/bin/perl -w # arrays (lists of scalars) # array names start with @ # define arrays by listing their contents in parentheses, # separated by commas # to retrieve the elements of an array, $array_name[element_index] # the element index numbers start with 0 # @aa_names = ('alanine', 'arginine', 'aspartate', 'asparagine', 'cysteine', 'glutamate', 'glutamine', 'glycine', 'histidine', 'isoleucine', 'leucine', 'lysine', 'methionine', 'phenylalanine', 'proline', 'serine', 'threonine', 'tyrosine', 'tryptophan', 'valine'); @aa_1codes = ('A', 'R', 'D', 'N', 'C', 'E', 'Q', 'G', 'H', 'I', 'L', 'K', 'M', 'F', 'P', 'S', 'T', 'Y', 'W', 'V'); @aa_3codes = ("Ala", "Arg", "Asp", "Asn", "Cys", "Glu", "Gln", "Gly", "His", "Ile", "Leu", "Lys", "Met", "Phe", "Pro", "Ser", "Thr", "Tyr", "Trp", "Val"); print "Enter the single letter code for an amino acid: "; chomp ($code=); for $i (0 .. 19) { if ($code eq $aa_1codes [$i]) { print $aa_names [$i], " ", $aa_3codes [$i], " ", $aa_1codes [$i], "\n"; } } exit; lenti265 [~/perltest]>perl arrays2.pl Enter the single letter code for an amino acid: a lenti266 [~/perltest]>perl arrays2.pl Enter the single letter code for an amino acid: B lenti267 [~/perltest]>perl arrays2.pl Enter the single letter code for an amino acid: C cysteine Cys C Enter the single letter code for an amino acid: Arg lenti268 [~/perltest]>perl arrays2.pl