#! /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 = ; 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"."$temp[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; }