develooper Front page | perl.beginners | Postings from March 2002

multidimensional hashes

Thread Next
From:
Chris Garaffa
Date:
March 3, 2002 08:18
Subject:
multidimensional hashes
Message ID:
2D239C88-2EC2-11D6-A2ED-003065FBBAF0@optonline.net
Hello all,
I'm working on a site for a t-shirt company, and doing the order process 
in Perl.
I've got everything working, and working fine, but I was wondering about 
different ways to go about doing this:

$the_order = new CGI;
$the_sleeve_type = $the_order->param('sleeve_type');
$the_previous_step = $the_order->param('step');
%product_to_number = ();
%number_to_description = ();
$product_to_number{"short"} = "21";
$product_to_number{"long"} = "20";
$number_to_description{"21"} = "short sleeved t-shirt";
$number_to_description{"20"} = "long sleeved t-shirt";

(The above is simplified... There are many entries in product_to_number 
and number_to_description, as well as many more params passed to 
$the_order.
Now, how do I go about defining multidimensional arrays, and then 
accessing them? What I have now is this:

$product_number = $product_to_number{$the_sleeve_type};
$product_description = $number_to_description{$product_number};
print "[$product_number] [$product_description] ";

but I'd like to be able to get rid of %product_description altogether 
and make calls to a multidimensional hash
Any ideas?

TIA,
Chris


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About