Hey, I was bored.
Not ready for production use. Not properly tested (in fact, tested only to the point where it would compile), and a lot more could be done to cast it in the PHP idiom.
But the Perl code is straightforward. No weirdness with special $-variables, no funky referencing/dereferencing, no anonymous functions, not even a regexp...