in reply to passing a regex to a sub

I think you just need to change the way the regex is quoted. Instead of using single quotes, try qr{}. Double quotes should also work.

Not had a chance to test this alas, but that's what I understand from my little book.

use JAPH;
print JAPH::asString();