Click here to get back home

Help with Hash of Hashes

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Help with Hash of Hashes Kevin Brammer 06-17-2008
Get Chitika Premium
Posted by sharma__r on June 18, 2008, 4:11 am
Please log in for more thread options
[...snipped...]


#!/usr/local/bin/perl

use strict;
use warnings;

my $NL = qq;

local $\ = $NL;

my %defaults = (
        entry1 => "0",
        entry2 => "0",
        entry3 => "0",
        entry4 => "0",
);

open my $inp_fh, '<', 'inp'
        or die "Cannot open the file [inp]: $!";

my %HoH;

my ($item, $knt);

while (my $line = <$inp_fh>) {
        chomp $line;

        if ($line =~ m/ \A \S+ /xms) {
                $item = $line;
                $HoH{ $item } = { %defaults };
                $knt = 0;
        }
        elsif ($line =~ m/ \A \s+ [-] \s+ \S /xms) {
                (my $entry = $line) =~ s/ \A \s+ [-] \s+ //xms;
                $HoH{ $item }->{ q . ++$knt } = $entry;
        }
}

close $inp_fh
        or die "Cannot close the file [inp] after reading: $!";
################### End ################

Similar ThreadsPosted
Performance Improvement of complex data structure (hash of hashes of hashes) August 24, 2004, 2:26 pm
Re: Performance Improvement of complex data structure (hash of hashes of hashes) August 25, 2004, 10:49 am
Re: Performance Improvement of complex data structure (hash of hashes of hashes) August 26, 2004, 7:19 am
Re: Performance Improvement of complex data structure (hash of hashes of hashes) August 26, 2004, 7:26 am
"Pseudo-hashes are deprecated" error and accessing a hash of hashes January 30, 2006, 4:04 pm
Hash of hashes, of hashes, of arrays of hashes October 27, 2005, 6:05 pm
Hashes of hashes or just one hash ? June 8, 2005, 6:09 am
Sorting a hash containing a hash of hashes December 14, 2005, 2:29 pm
Help with Hash of Hashes March 1, 2006, 1:54 pm
Hash of hashes April 10, 2006, 5:15 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap