perl library for n-ary encoding