Customer | Money spent
-----------------+-------------
Fred Flintstone | 1000
Barney Rubble | 2000
... | ...
I'll assume from this point on that that's the case.
How to best go about this depends on how %myHash is structured, exactly. If it's a hash of hashes, holding (for each customer) a hash with several pieces of information, including the money they spent, proceed as in Re: Keys and Values from Hash to obtain a hash containing only, for each customer, the amount of money they spent. Your original post suggests that this is the case.
If it's already a hash of that form, you're done. Your reply at Re^2: Keys and Values from Hash suggests that this is the case instead.
Either way, once you've got the resulting hash, simply iterate over it and output HTML in some way to create your page:
foreach my $customer (keys %money_spent) {
my $money_sent_by_this_customer = $money_spent{$customer};
# do something with $customer and $money_spent_by_this_customer
}
That said, you may not even need to do any of this; you could equally well just do this, obviating the need for an intermediate hash entirely:
foreach my $customer (keys %myHash) {
my $money_sent_by_this_customer = $myHash{$customer}->{"money"};
# do something with $customer and $money_spent_by_this_customer
}
I hope this helps.
BTW, I'm getting the feeling that you're not so familiar/at ease with the concept of hashes as such yet. Be sure to read up on them -- see Associative array, Programming Perl p. 76-77 (page numbers for 3rd edition), perldata, perlfaq4: Data: Hashes (Associative Arrays), Not Exactly a Hash Tutorial, Perl Hash Howto, etc.
EDIT: re: your added important info, if you've only got two data points for each customer, money spent at 9am and money spent at 3pm, I'd recommend simply using two separate hashes, each constructed as above. That, or (again) don't use intermediate hashes at all, and just do this:
foreach my $customer (keys %myHash) {
my $money_sent_by_this_customer_at_9am = $myHash{$customer}->{"mon
+ey9am"};
my $money_sent_by_this_customer_at_3pm = $myHash{$customer}->{"mon
+ey3pm"};
# do something with $customer, $money_spent_by_this_customer_at_9a
+m and $money_spent_by_this_customer_at_3pm
}
|