perl solution #41