I didn't know, where exactly did go wrong. Please check my code and let me know the mistake please.
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++) { @fields=split /\s+/,$file[$i]; $samplehash{$fields[1]}{$fields[0]}=$fields[2]; } foreach $key (keys %samplehash) { print "\n $key = $samplehash{$key} "; foreach $subkey (keys %samplehash{$key}) { print "\n $subkey = $samplehash{$key}{$subkey} "; } } close S;
Thanks in advance
In reply to Assign and print Hash of hashes by sundeep
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |