hash_ref_slice function to use before perl-5.20