## Forum archive 2000-2006

### Nandor Sieben - evaluator confusion

by Arnold Pizer -
Number of replies: 0
 evaluator confusion topic started 7/14/2005; 12:49:09 AMlast post 7/14/2005; 9:19:05 AM
 Nandor Sieben - evaluator confusion  7/14/2005; 12:49:09 AM (reads: 646, responses: 2) 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_TEXTHow much is 5+2?{ ans_rule(10) }END_TEXTANS( 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 |>  Nandor Sieben - Re: evaluator confusion 7/14/2005; 1:42:15 AM (reads: 834, responses: 0) I got it. Now I know that there are old style and new style evaluators. I need$myeval_evaluate($in). Where can I find info about the answer evaluator object? <| Post or View Comments |>  Michael Gage - Re: evaluator confusion 7/14/2005; 9:19:05 AM (reads: 839, responses: 0) The old style (for Perl 4) is described at http://webwork.math.rochester.edu/docs/docs/pglanguage/answerevaluators.html#WAEF. There is also some discussion at http://webhost.math.rochester.edu/webworkdocs/discuss/msgReader$763 about handling old and new style answer evaluators. I encourage you to use the AnswerEvaluator object as described in AnswerHash.pm. You may need to look at the code itself. For modifying existing answer evaluators, which is a lot of what you are trying to do at the moment, take a look at the code in PGasu.pl. John Jones has a number of straightforeward examples of modifying existing answer evaluators. Hope this helps. -- Mike <| Post or View Comments |>