in reply to Not a HASH reference

Your XML has 2 SD elements

<SD TITLE="A" FLAGS="" HOST="gamegrene.com"> <TITLE TEXT="Gamegrene"/> <OWNER NAME="Disobey"/> </SD> <SD> <POPULARITY URL="gamegrene.com/" TEXT="6678166" SOURCE="panel"/> <REACH RANK="5826716"/> <RANK DELTA="-550802"/> </SD>

XMLin builds the structure as

{ SD => [ { FLAGS => "", HOST => "gamegrene.com", OWNER => { NAME => "Disobey" }, TITLE => ["A", { TEXT => "Gamegrene" }], }, { POPULARITY => { SOURCE => "panel", TEXT => 6678166, URL => + "gamegrene.com/" }, RANK => { DELTA => -550802 }, REACH => { RANK => 5826716 }, }, ], }

therefore $xml->{SD} is an arrayref not a hashref

poj

Replies are listed 'Best First'.
Re^2: Not a HASH reference
by fdavidg2019 (Initiate) on Jul 09, 2019 at 23:44 UTC

    So when I check for an array in line 69 like this:

    if (ref($xml->{SD}{AMZN}{PRODUCT}) eq "ARRAY")

    it should return TRUE, but I keep getting a "NOT HASH reference" error at this line! Frank

      $xml->{SD} is an arrayref, so $xml->{SD}{AMZN} is not a thing.

      I strongly advise switching to a saner XML module. XML::LibXML is my favourite.