From 5257595639f06138e5021b19e71970d6c1bfef99 Mon Sep 17 00:00:00 2001 From: Mercier Pierre-Olivier Date: Thu, 26 Sep 2013 01:38:05 +0200 Subject: [PATCH] Pass $ref to functions --- ACU/Grading.pm | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/ACU/Grading.pm b/ACU/Grading.pm index a88424c..81fd4aa 100644 --- a/ACU/Grading.pm +++ b/ACU/Grading.pm @@ -239,13 +239,13 @@ sub compute ($$$;$$$) { $grade = $doc->createElement("grade"); $grade->addChild( $doc->createAttribute("factor", $self->{factor}) ); - $grade->addChild( $doc->createAttribute("name", $self->{title}) ); + $grade->addChild( $doc->createAttribute("name", $self->{title}) ) if ($self->{title}); $parent->appendChild( $grade ); } for my $node (@{ $self->{tree} }) { - my $t = $node->compute($operators, $ids, $doc, $grade); + my $t = $node->compute($operators, $ids, $login, $doc, $grade); push @current, $t if (defined $t); } @@ -315,16 +315,17 @@ sub toString ($$$) $parent->appendChild($point); } -sub getValue ($$) +sub getValue ($$$) { my $self = shift; my $ids = shift; + my $ref = shift; # Return the point node value if exists return $self->{value} if ($self->{value} ne ""); # Else return pointed ref value - return $ids->{ $self->{ref} }; + return $ids->{ $ref }; } sub compute ($$$;$$$) @@ -352,15 +353,15 @@ sub compute ($$$;$$$) $result = !$result if ($self->{not}); # ret is valued only if all conditions passed - $ret = $self->getValue( $ids ) if ($result); + $ret = $self->getValue( $ids, $ref ) if ($result); if ($main::debug) { - my $str = "not=".($self->{not}//0).", qversion".($self->{qversion}//"*").", ref=".($ref//"").",\tvalue=".($ids->{ $ref//"" } // "undef").", "; + my $str = "not=".($self->{not}//0).", qversion".($self->{qversion}//"*").", ref=".($ref//"").",\tvalue=".($ids->{ $ref//"" } // "undef"); if ($result) { - say GREEN, ">>>", RESET, " Matching point: ", $str, BOLD, "got=".($ret // 0), RESET; + say GREEN, ">>>", RESET, " Matching point: ", $str, ", ", BOLD, "got=".($ret // 0), RESET; } else { - say RED, " * ", RESET, " Skipped point: ", $str, BOLD, "got=".($ret // 0), RESET; + say RED, " * ", RESET, " Skipped point: ", $str; } }