Unfortunately, I'm not fluent at all in PERL -- and even less familiar with WebWork's design and implementation. I pasted the entire subroutine into a fresh file, added a command at the bottom of the file to run that subroutine, and executed the file with wwsh. I got complaints of uninitialized variables and decided I'd reached the end of my competency. :)
I'll post this into GitHub issues in case someone else considers this a worthwhile improvement to the application. Thanks for helping me out!