re-write given/when to something backward/forward compatible

given/when is experimental in perl5.18, and it shows a lot of warnings