tidying perl codes