Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: perl hash problem for comparing two files

by Utilitarian (Vicar)
on Mar 25, 2011 at 06:56 UTC ( [id://895406]=note: print w/replies, xml ) Need Help??


in reply to perl hash problem for comparing two files

You have an unnecessary set of parentheses where you declare your sub, assuming you didn't mean to set an invalid prototype, you should use code tags around code as otherwise the array indices are linkified and indentation is lost.
#! /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; }
running this gives you
$VAR1 = { 'PRO A' => '6', 'TRP A' => '7' };

print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://895406]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-19 22:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found