Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Data from a Hash/Array

by toolic (Bishop)
on Sep 05, 2012 at 19:44 UTC ( #991926=note: print w/ replies, xml ) Need Help??

in reply to Data from a Hash/Array

Assuming those colons are really fat commas (=>):

use warnings; use strict; my $code = { "StatusCode"=> 0, "StatusInfo"=> "Command Processed OK", "PageNumber"=> 0, "TotalPageCount"=> 1, "TotalProductCount"=> 1, "PageProductCount"=> 1, "Products"=> [ { "BaseProductId"=> "50043662", "EANBarcode"=> "5000175411118", "CheaperAlternativeProductId"=> "", "HealthierAlternativeProductId"=> "", "ImagePath"=> "http=>// +Shot_90x90.jpg", "MaximumPurchaseQuantity"=> 99, "Name"=> "Oxo 12 Chicken Stock Cubes 71G", "OfferPromotion"=> "Price Drop Was 1.13 Now 1.00 ", "OfferValidity"=> "valid from 30/7/2012 until 9/9/2012", "OfferLabelImagePath"=> "http=>// +tes/Retail/Superstore/Online/Product/pos/save.png", "Price"=> 1, "PriceDescription"=> "1.41 each", "ProductId"=> "254881114", "ProductType"=> "QuantityOnlyProduct", "UnitPrice"=> 1.41, "UnitType"=> "100g" } ] } ; print $code->{Products}[0]{ProductId},"\n"; __END__ 254881114

See also:

Comment on Re: Data from a Hash/Array
Select or Download Code
Replies are listed 'Best First'.
Re^2: Data from a Hash/Array
by foggy3657 (Novice) on Sep 05, 2012 at 20:50 UTC

    Thank you very much toolic. Your assistance was really appreciated. I will read up on the links, but an initial glance tells me I've a long way to go before I understand half of it. Couple of questions. Not sure I understood your reference to fat commas - they were in fact colons - but your code worked in any event. What was the returned data, was it a hash or an array? I need to read something a little easier than perldsc to understand the code you posted. Once again thank you for helping Best wishes. James.

      Thank you very much toolic.
      You're welcome.
      Not sure I understood your reference to fat commas
      See Fat_comma and Comma Operator

      Regarding my solution... don't use it :) Other monks are on to the real problem, that you need to look into parsing JSON.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://991926]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2016-02-12 02:51 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (388 votes), past polls