implement tac in perl