refactored the perl parser