# assuming $obj->{attr_name} holds a hashref return $obj->{attr_name}; } # code passes foreach my $item (keys %{ $obj->method() }) {