###################### # Directives # ###################### use strict; use warnings; ###################### # Main Code # ###################### sub expand_name; my @result = expand_name(@ARGV); my $i=0; # i,j,k,etc. are the traditional names for general purpose loop counters or iterators foreach (@result) { if ($_) { print "$ARGV[$i] is $_\n"; } else { print"Sorry bub. $ARGV[$i] is not an amino acid.\n"; } $i++; } ###################### # Subroutines # ###################### sub expand_name { my $amino_acid; my @return_list; my %convert = ( "S" => "Ser", "F" => "Phe", "L" => "Leu", "Y" => "Tyr", "C" => "Cys", "W" => "Trp", "P" => "Pro", "H" => "His", "Q" => "Glu", "I" => "Iso", "M" => "Met", "T" => "Thr", "N" => "Asp", "K" => "Lys", "V" => "Val", "D" => "Asp", "E" => "Glu", "G" => "Gly", "R" => "Arg", "A" => "Ala" ); foreach $amino_acid (@_) { push (@return_list, $convert{$amino_acid} ) } @return_list; ## this returns the list that we are putting into @result above. }