perl solution #34