perlunity.de - PERL | JAVASCRIPT | PHP | MySQL | APACHE



#!/COMMUNITY

Members: 5374
davon online: 1
weitere User: 28
Click for quality!




10.02.2012 / 20:15

Community-Member werden   |   Paßwort vergessen   |   OnlineMonitor (1) Wer ist online ... OnlineMonitor starten !
     

 

Home


PERLscripts


PHPscripts


JAVAscripts


Hilfreiches


Links2www


Newscenter


Community


Interna




Community  »  Perl: Allgemeines Forum zur Themenübersicht Themensuche Themenansicht in Thread-Modus


BeitragHash of Hashes
Seitenanfang
Hallo,

ich möchte einen Hash von Hashes nutzen. Ich kann auch Hashes hinzufügen, doch nicht wieder auslesen. So versuche ich's:


#! /opt/VFD2tools/perl5.8.6/bin/perl

use strict;

my $errorcode = "OFF000041";
my %hoh; # hash of hashes
my %writehash;

$writehash{"2008-01-27"} = 45;
$writehash{"2008-01-28"} = 17;

my $itemcount = keys(%writehash);
print "number of entries in writehash: ".$itemcount."\n";
print "number of entries in writehash: ".keys(%writehash)."\n";
print "keys of writehash:\n";
my @hashitems = keys(%writehash);
foreach(@hashitems) {
print "$_\n";
}

$hoh{$errorcode}=%writehash;

my $itemcount = keys(%hoh);
print "number of entries in hoh: ".$itemcount."\n";
print "number of entries in hoh: ".keys(%hoh)."\n";
my %readhash = $hoh{$errorcode};
my $itemcount = keys(%readhash);
print "number of entries in readhash: ".$itemcount."\n";
print "number of entries in readhash: ".keys(%readhash)."\n";
print "keys of readhash:\n";
my @hashitems = keys(%readhash);
foreach(@hashitems) {
print "$_\n";
}

Doch das ist die Ausgabe (writehash und readhash sollten gleich sein):

 
number of entries in writehash: 2
number of entries in writehash: 2
keys of writehash:
2008-01-28
2008-01-27
number of entries in hoh: 1
number of entries in hoh: 1
number of entries in readhash: 1
number of entries in readhash: 1
keys of readhash:
2/8

Datum: 03.03.2008-21:23

Beitragre: Hash of Hashes
Seitenanfang
Schau Dir mal http://wiki.perl-community.de/bin/view/Perldoc/perlreftut an...

Datum: 04.03.2008-13:47

-






-
-