perl loop refactor
perl loop refactor