refactor the perl binding