For college, we need to make a script in Perl, which allows us to manage inventory for an electronic store. (The given example was Amazon). Users can place orders in a fully text environment, and inventory must be updated after order completion.
Each item in the inventory has from 3 to 4 attributes: product code, title, price and some amount (for example, MP3 does not have this attribute)
Since this is my first meeting with Perl, I don’t know how to start. My main problem is how I should “implement” the inventory in the program. One of the functions of the program is a search by name. Another is to place an order where the user must specify the product code.
My first idea was a hash with product code as a key. But if I wanted to look in the headers that might be the problem because of this: hashkey will be something like DVD-123, the information belonging to this key could be “Green Mask 12” (without quotes), where 12 indicates how many of this DVDs are currently in stock. So I would have to find a way to ignore 12 at the end.
Another solution was to use the name as a key, but that would also be cumbersome.
Is there a way to make a hash table with two keys, and when I give only one, it returns an array with other values? (Including another key and other information) Thus, I could use a different key depending on what information I need from my inventory.
, :
MP3-72|Lady Gaga - Kiss and Run (Fear of Commitment Monster)|0.99
CD-400|Kings of Leon - Only By The Night|14.50|2
MP3-401|Kings of Leon - Closer|0.85
DVD-144|Live Free or Die Hard|14.99|2
SOFT-864|Windows Vista|49.95