in reply to Re: Parse a file and store it in hash of hashes
in thread Parse a file and store it in hash of hashes
This is my code snippet. When i run this program there is no output at all. I am not able to figure out why
#!/usr/local/bin/perl use strict; use warnings; use Data::Dumper; my $filename = 'tester.txt'; my %HoH; my $key; my $value; open(my $fh, '<:encoding(UTF-8)', $filename) or die "Could not open file '$filename' $!"; while ( <$fh> ) { next unless s/^\[(.*?)\]\s*//; $rec = $1; for my $field ( split /\n/) { ($key, $value) = split /\s*=\s*/, $field; $HoH{$rec}{$key} = $value; } } print Dumper %HoH;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Parse a file and store it in hash of hashes
by Corion (Patriarch) on Jan 16, 2017 at 08:34 UTC | |
by Sonali (Novice) on Jan 16, 2017 at 10:07 UTC | |
Re^3: Parse a file and store it in hash of hashes
by Discipulus (Canon) on Jan 16, 2017 at 08:43 UTC | |
by Sonali (Novice) on Jan 16, 2017 at 09:51 UTC | |
by Discipulus (Canon) on Jan 16, 2017 at 10:06 UTC | |
by Sonali (Novice) on Jan 16, 2017 at 11:45 UTC | |
by johngg (Canon) on Jan 16, 2017 at 12:22 UTC | |
| |
by Corion (Patriarch) on Jan 16, 2017 at 11:51 UTC |