baskets-perl-exam

image

to run use this command perl index.pl

Grocery Basket Test

You have data in the following JSON format: ` [

{

    "name":"apples",

    "baskets":[10,20,30]

},

{

    "name":"bananas",

    "baskets":[5,20,10,10]

}

] ` name is the name of a grocery product.

baskets is a list that contains the quantity in each basket sold.

Write a Perl script that displays for each product the total number of baskets and the total number of products. For example:

60 apples in 3 baskets

45 bananas in 4 baskets

The script need not accept any arguments; the above data can be hard-coded.
The script need not convert from JSON. You may choose to hard-code the data in a structure of your choice.
The script MUST calculate the results; it MUST NOT print hard-coded results.