backport to Perl 5.6.1 assuming relatively recent List::Util
test with/without XS