#!/usr/bin/perl -w
#In page 369 of the Cookbook, I saw that they have a "person" record stored
into the scalar "$Nat", like so:
$Nat = { "Name" => "Guy Person",
"Address" => "123 Itsgee Place",
"Age" => 34,
};
#Say you indexed this by $AcctNo:
$AcctNo = "P123-456";
%Accts = ();
$Accts{$AcctNo} = $Nat;
#How do you then retrieve the record by field name?
#The Account number is easy...
foreach $account (keys %Accts) {
print "Account: $account\n";
}
#But when I try to pluck a fields value out, I get hosed
foreach $account (keys %Accts) {
print "Fields: \n";
foreach $name (keys $Accts{$account}) {
#here's where my brainstorming turns into a light sprinkle
#there's a scalar here ($Accts{$account}) but I need a hash at this
point, correct?
print "$name : ($Accts{$account}{$name})\n";
#don't work
}
}
#Any help mightly appreciated.
#Joel