Functional version in pure lisp (no perl required).