in reply to HASH error

Put a

print Dumper($ref), "\n";

before the line

foreach my $oid (values %{$ref->{OBJECT}}) {

and show us the output. You also have to put a

use Data::Dumper;

below the line

use JSON;

McA

Replies are listed 'Best First'.
Re^2: HASH error
by Sententiosus (Initiate) on Sep 13, 2013 at 08:21 UTC

    thanks McA

    the Output

    $VAR1 = { 'OBJECT' => { 'PROPERTY' => [ { 'content' => 'error', 'name' => 'response-type' }, { 'content' => '1', 'name' => 'response-type-numer +ic' }, { 'content' => 'Unauthorized acc +ess requested', 'name' => 'response' }, { 'content' => '6', 'name' => 'return-code' } ], 'oid' => '1', 'name' => 'status', 'basetype' => 'status' } }; Not a HASH reference at ./hp-msa.pl line 19.

      As I'm not the author of that program I can only guess. Please change the line:

      my $ref = XMLin($res->content, KeyAttr => "oid");

      to the following

      my $ref = XMLin($res->content, KeyAttr => "oid", ForceArray => [ 'OBJE +CT' ]);

      and give it a try.

      McA