answer 3 in perl