From 3fba804746b059d08950e3810bca32829a70f904 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Sat, 2 Dec 2023 11:15:10 -0800 Subject: [PATCH] address 'address' issue #872 --- lib/Value.pm | 3 +-- macros/answers/answerHints.pl | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/Value.pm b/lib/Value.pm index 1b3897e446..4c7b799fc7 100644 --- a/lib/Value.pm +++ b/lib/Value.pm @@ -267,13 +267,12 @@ sub inContext { my $self = shift; $self->context(@_); $self } ############################################################# -# # # The address of a Value object (actually ANY perl value). # Use this to compare two objects to see of they are # the same object (avoids automatic stringification). # -sub address { oct(sprintf("0x%p", shift)) } +sub address { Scalar::Util::refaddr(shift) } sub isBlessed { (Scalar::Util::blessed(shift) // '') ne "" } sub blessedClass { Scalar::Util::blessed(shift) } diff --git a/macros/answers/answerHints.pl b/macros/answers/answerHints.pl index 4da47e88ee..e836441043 100644 --- a/macros/answers/answerHints.pl +++ b/macros/answers/answerHints.pl @@ -200,12 +200,12 @@ sub Compare { $ans->{ans_message} = $ans->{error_message} = ""; $ans->{score} = 0; - if (sprintf("%p", $self) ne sprintf("%p", $ans->{correct_value})) { + if ($self->address != $ans->{correct_value}->address) { $ans->{correct_ans} = $self->string; $ans->{correct_value} = $self; $ans->{correct_formula} = Value->Package("Formula")->new($self); } - if (sprintf("%p", $other) ne sprintf("%p", $ans->{student_value})) { + if ($other->address != $ans->{student_value}->address) { $ans->{student_ans} = $other->string; $ans->{student_value} = $other; $ans->{student_formula} = Value->Package("Formula")->new($other);