perl refactoring