This should get you in the right direction..
use strict;
my %oldhash = (
'hygiene_products' => {
'conditioner' => "5",
'shampoo' => "50",
'soap' => "1"},
'cleaning_products' => {
'mops' => "20"
}
);
my %newhash;
foreach(keys %oldhash) {
my $item_count;
foreach my $item(keys %{$oldhash{$_}}) {
$item_count++;
$newhash{$_}{"item_$item_count"}=$item;
$newhash{$_}{"quantity_$item_count"}=$oldhash{$_}{$item};
}
$newhash{$_}{'num_items'}=$item_count;
}
foreach(sort keys %newhash) {
print "Hash Set: $_\n";
foreach my $item (sort keys %{$newhash{$_}}) {
print " Name: $item Value: $newhash{$_}{$item}\n";
}
}
Shawn
----- Original Message -----
From: "Mark Hanson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, December 02, 2001 5:42 PM
Subject: Urgent! creating new hash from hash based on format of another hash
%newhash = (
hygiene_products => {
quantity_3 => "50",
item_2 => "soap",
item_3 => "shampoo",
num_items => "3",
quantity_1 => "5",
quantity_2 => "1",
item_1 => "conditioner",
},
cleaning_products => {
num_items => "1",
quantity_1 => "20",
item_1 => "mops",
},
);
%oldhash = (
hygiene_products => {
conditioner => "5",
shampoo => "50",
soap => "1",
},
cleaning_products => {
"mops" => "20",
},
);
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]