I have two file of given structure
File 1 structure :
SER A ARG A GLU A LYS A ASN A GLN A PRO A LYS A PRO A SER A PRO A LYS A ARG A
File 2 structures (PDB file):
ATOM 2 CA PRO A 6 2.437 5.295 -23.029 1.00 0.00 + C ATOM 3 C PRO A 6 2.307 5.113 -21.515 1.00 0.00 + C ATOM 4 O PRO A 6 3.276 4.869 -20.823 1.00 0.00 + O ATOM 15 N TRP A 7 1.114 5.225 -20.998 1.00 0.00 + N ATOM 16 CA TRP A 7 0.916 5.054 -19.531 1.00 0.00 + C ATOM 17 C TRP A 7 0.772 3.567 -19.197 1.00 0.00 + C <>

the above given two file I have to match file one value with third column value(PRO A) of second which is repeated but I have to consider this only one and pick the column fourth value(6). i have created I subroutine for that for first time it matching correctly but for second file it has missing some value.these both file value will change after completion of first time.

MY code
sub parse_pdb() { my $file = shift; my %hash_pdb = (); # Opening of PDB file after dowloading open(FH, $file); @atomrecord = <FH>; foreach my $record (@atomrecord) { chomp($record); if($record =~/^ATOM/) { @temp = split(/\s+/, $record); $con_key = ""; $con_key = "$temp[3]"." "."$temp[4]"; $count = 0; if( $hash_pdb{$con_key} ) { if($val_seen{$temp[5]}) { } else { $hash_pdb{$con_key} = $hash_pdb{$con_key}."\t"."$t +emp[5]"; } } else { $hash_pdb{$con_key} = $temp[5]; } $val_seen{$temp[5]} = 1; } if($record =~ /^ENDMDL/){ print "i am going out of loop\n"; last; } } return \%hash_pdb; }
thanks in advance

In reply to perl hash problem for comparing two files by sarf13

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.