perl solution #22