Guest User

Untitled

a guest
Jan 21st, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. # ritorna un array di prodotti rappresentati
  2. # come hash da attributi del prodotto a valori
  3. sub get_products {
  4. my $product_list = get_list($products_xml);
  5. my @products = ();
  6. foreach my $p ($product_list->findnodes('//ns:product')) {
  7. my @ingredients = $p->findnodes("ns:ingredient_list//ns:ingredient");
  8. my %product = {
  9. 'product_id' => $p->findvalue('ns:product_id'),
  10. 'name' => $p->findvalue('ns:name'),
  11. 'description' => $p->findvalue('ns:description'),
  12. 'price' => $p->findvalue('ns:price'),
  13. 'picture' => img_path($p->findvalue('ns:picture')),
  14. 'ingredients' => @ingredients
  15. };
  16. push(%product, @products);
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment