You can use PG_restricted_eval (described in PGbasicmacros.pl)
I recommend updating to ww188.8.131.52 (or ww184.108.40.206 if you are somewhat
brave -- we're readying that for general release very soon. I use it now). It's available at github.com/openwebwork.
There is a lot of programmers resources on the wiki -- but some of it is out of date. The MathObjects descriptions are the most recent but are not really at the programming level.
Make good use of the POD descriptions: linked to from
http://webwork.maa.org/wiki/Category:Authors and the search engine. For
Paul Pearson's document http://webwork.maa.org/wiki/File:WeBWorK_Problem_Authoring_Tutorial.pdf is a good basic reference but may dwell longer on basic perl than you need to.
And look at this collection: http://webwork.maa.org/moodle/mod/data/view.php?id=5
of 'all' the macros defined in PG. (This is somewhat out of date which is why
all is in quotes. There is a lot of documentation which is out of date but which is still relevant. Most problems coded 15 years ago will still run, but it is desirable to look around before copying them too closely.
For basic perl I think the book "Learning Perl" by Schwartz remains on of the best. I've also looked at "Modern Perl" by chromatic as a guide for new coding methods that are more in step with current practice. I'd like to incorporate some those into our WeBWorK code updates -- although they
require at least perl 5.10 and often perl 5.12 or 5.14.
And feel free to ask questions on this forum. If you see places where you can help out with the documentation for coding please do. We'll be glad to help as well.