The
following code doesn't work. It gives the warning: not a CODE
reference. I would like to write my own evaluator that calls a standard
evaluator.
TEXT(&beginproblem); sub ans_eval { my $correct = shift; my $myeval = num_cmp($correct); sub { my $in = shift; my $ans_hash = &$myeval($in); # modife $ans_hash here a little $ans_hash; } }
BEGIN_TEXT How much is 5+2? { ans_rule(10) } END_TEXT
ANS( ans_eval(7) );
What is the problem with it? The following simple perl
code works, and I would think the answer evaluator uses the same
principle except it returns a reference to an answer hash. #!/usr/bin/perl -w
sub ff {
my $c = shift;
sub {
my $a = shift;
$c*$a;
}
}
$reff = ff(2);
print &$reff(3);
<| Post or View Comments |>
|