in reply to perl hash problem for comparing two files
running this gives you#! /usr/bin/perl use strict; use warnings; my $hash_ref= parse_pdb("pdb.txt"); use Data::Dumper; print Dumper($hash_ref); sub parse_pdb{ my $file = shift; my %hash_pdb = (); my %val_seen=(); # Opening of PDB file after dowloading open(FH, $file); my @atomrecord = <FH>; for my $record (@atomrecord){ chomp($record); if($record =~/^ATOM/) { my $con_key = ""; $con_key = "$temp[3]"." "."$temp[4]"; my $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; }
$VAR1 = { 'PRO A' => '6', 'TRP A' => '7' };
|
|---|