Please look at the following code
use strict; use warnings; use Data::Dumper; open (S,"<","sample.data") or die $!; my @file=<S>; my %samplehash; my @fields; my ($key,$subkey); for ( my $i=0;$i<=$#file;$i++) { chomp $file[$i]; @fields=split /\s+/,$file[$i]; $samplehash{$fields[1]}{$fields[2]}=$fields[0]; } foreach $key (keys %samplehash) { print "\n $key = ". $samplehash{$key}; foreach $subkey (keys %{$samplehash{$key}}) { print "\t$subkey = $samplehash{$key}{$subkey} "; } } close S;
This is the input file
cow NM_178575.2 0 cow NM_181451.1 1 cow NM_001038581.1 2 cow NM_001037618.1 3 cow NM_001034757.1 4 cow NM_001076304.1 5 cow NM_001076305.1 6 cow NM_001076273.1 7 cow NM_001076486.1 8 cow NM_001076951.1 9 cow NM_001077070.1 10 cow NM_001077006.1 11 cow NM_001078104.1 12 cow NM_001078077.1 13 cow NM_001077830.1 14 cow NM_001079784.1 15 cow NM_001078135.1 16 cow NM_001080323.1 17 cow NM_001080346.1 18 cow NM_001080347.1 19 cow NM_174222.2 20 cow NM_001080364.1 21
When i try to print the key of the first hash table, using print "\n $key = ". $samplehash{$key};, i see the output something very weird as follows :
NM_001077006.1 = HASH(0x224be2c) 11 = cow
Can someone tell me the problem with my print statement, please. I didn't understand what is the HASH(0x224be2c) ,when i am expecting it to print 11
In reply to Print the key of the first hash table in hash of hashes by sundeep
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |