perl solution #27