oops..mistake!!
$intHash1Ref = {'A' => 'B'};
$intHash2Ref = {'C' => 'D'};
%containerHash = ('hash1' => $intHash1Ref, 'hash2' => $intHash2Ref);
foreach my $hashRefKeys (keys %containerHash) {
my $hashRef = $containerHash{$hashRefKeys};
foreach my $hashKeys (keys %{$hashRef} ) {
print $hashKeys, " ", $hashRef->{$hashKeys},"\n";
}
}
-----Original Message-----
From: Shishir K. Singh
Sent: Monday, March 03, 2003 12:42 PM
To: 'Hanson, Rob'; 'Yannick Warnier'; [EMAIL PROTECTED]
Subject: RE: adding hash reference into hash
You may want to handle them as
$intHash1Ref = {'A' => 'B'};
$intHash2Ref = {'C' => 'D'};
%containerHash = ('hash1' => $intHash1Ref, 'hash2' => $intHash2Ref);
foreach my $hashRefKeys (keys %containerHash) {
foreach my $hashKeys (keys %{$containerHash{$hashRefKeys}} ) {
print $hashKeys, " ", $hashRef->{$hashKeys},"\n";
}
}
Output is
C D
A B
-----Original Message-----
From: Hanson, Rob [mailto:[EMAIL PROTECTED]
Sent: Monday, March 03, 2003 12:14 PM
To: 'Yannick Warnier'; [EMAIL PROTECTED]
Subject: RE: adding hash reference into hash
Your syntax is a little off...
$intHash1Ref = {};
$intHash2Ref = {};
# note use of parens, not curly braces
%containerHash = (hash1 => $intHash1Ref, hash2 => $intHash2Ref);
The parens store a list into %containerHash, the curly-braces were storing a
hash-ref.
Rob
-----Original Message-----
From: Yannick Warnier [mailto:[EMAIL PROTECTED]
Sent: Monday, March 03, 2003 11:40 AM
To: [EMAIL PROTECTED]
Subject: adding hash reference into hash
Hi,
I'm just trying to make a structure with a hash containing some
references to other (yet unused) hashes.
So what I wrote this:
$intHash1Ref = {};
$intHash2Ref = {};
%containerHash = { hash1 => $intHash1Ref, hash2 => $intHash2Ref};
Then when I try to have a list of keys to that containerHash:
print keys(%containerHash);
I get some hexadecimal values like:
HASH(0x813f9b0)
How can I manage to do that cleanly?
I'm searching in "Programming Perl 3th Ed." for that but I don't get
it... yet.
Yannick
_____________________________________________________________________
Envie de discuter en "live" avec vos amis ? T�l�charger MSN Messenger
http://www.ifrance.com/_reloc/m la 1�re messagerie instantan�e de France
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]