perl solution #30