perl solution #23