WeBWorK Main Forum

Perl pack() in PG?

Perl pack() in PG?

by Stephen Corwin -
Number of replies: 1
Hi--

I've just found that pack() is not allowed in PG, at least in WeBWorK v2.2. Is there a substitute?

BTW, I presume that pack() is trapped by WWSafe/Opcode, but I can't find anything in the WWSafe code that does it explicitly, and the Opcode docs say that pack() is :still_to_be_decided, which WWSafe doesn't use. Just out of curiosity (and because I'd still like to contribute to this project someday when I have more time), where does that happen?

One possibility is that though I'm forced to use the now-antique v2.2 for my classes, I'm reading much more recent code (v2.5). Maybe it used to be trapped but is no longer? Another, and much more likely, possibility is that I missed something; I don't really understand Safe/Opcode.

And, as long as I've got your attention...I've hacked together an answer checker that can check a few simple MS Excel formulas and can be pretty easily extended to add more Excel functions. Would anyone be interested in that? If so, to whom should I send it? I have a Parse::RecDescent version also if anyone is interested. I can't call P::RD on my school's installation, and the standalone code that P::RD generates is ~7400 lines, so I've never even uploaded it; it seems silly when the 200-line hack works fine for what I need.

Thanks,

Steve
In reply to Stephen Corwin

Re: Perl pack() in PG?

by Michael Gage -
The Safe.pm code is called in the files pg/lib/WeBWorK/PG/Translator.pm
and perhaps also in webwork2/lib/WeBWorK/PG/Local.pm.  While I'm not sure, I suspect the code included acceptable functions rather than excluding unacceptable ones and I'm not surprised that pack() was not included.

If you want to include the your macros you can submit them as a patch to github.com/openwebwork.

Probably the best bet is to place them in a macro file and ask that the macro file be included in the webwork-open-problem-library  along with your questions that use those macros.  John Jones of Arizona State University is currently supervising the admission of such patches into the OPL.

-- Mike