http://qs321.pair.com?node_id=11149456


in reply to Issues regarding for loops and recursion

Hi Nickmofoe, and welcome to Perl!

if ($_=~m/^ATOM\s+\d+\s+\w+\s+\w+\s+\w+\d+\s+(\S+)\s+(\S+)\s+(\S+)/){

Here you match against $_, but it was never set. Did you want to match against $seq? I'm not sure.

Some general stylistic things:

open (IN, '6U9D.pdb.txt');

You should check whether opening the file actually succeeded:

my $filename = '6U9D.pdb.txt'; open (IN, $filename) or die "Couldn't open '$filename': $!";

You should use the strict pragma. This requires you to declare all variables but on the upside, it allows Perl to tell you about typos in your variable names.

When assigning the %amino_acid_conversion, you could use newlines to make the code a bit more readable:

%amino_acid_conversion = ( ALA=>'A', TYR=>'Y', MET=>'M', LEU=>'L', CYS=>'C', GLY=>'G', ARG=>'R', ASN=>'N', ASP=>'D', GLN=>'Q', GLU=>'E', HIS=>'H', TRP=>'W', LYS=>'K', PHE=>'F', PRO=>'P', SER=>'S', THR=>'T', ILE=>'I', VAL=>'V' );