qwurx [shmem] .../build/perl-5.25.10> grep hv_iternext_flags *.c *.h hv.c: while ((entry = hv_iternext_flags(ohv, 0))) { hv.c: while ((entry = hv_iternext_flags(ohv, 0))) { hv.c:=for apidoc hv_iternext_flags hv.c:Perl_hv_iternext_flags(pTHX_ HV *hv, I32 flags) hv.c: HE * const he = hv_iternext_flags(hv, 0); hv.c: while ((entry = hv_iternext_flags(hv, HV_ITERNEXT_WANTPLACEHOLDERS))) { mathoms.c: return hv_iternext_flags(hv, 0); mro_core.c: /* This is partly based on code in hv_iternext_flags. We are not call- perl.c: while ((entry = hv_iternext_flags(dups, 0))) { perlmini.c: while ((entry = hv_iternext_flags(dups, 0))) { regcomp.c: while ( (temphe = hv_iternext_flags(hv,0)) ) { regcomp.c: while ( (temphe = hv_iternext_flags(hv,0)) ) { embed.h:#define hv_iternext_flags(a,b) Perl_hv_iternext_flags(aTHX_ a,b) hv.h:/* Flags for hv_iternext_flags. */ hv.h:#define hv_iternext(hv) hv_iternext_flags(hv, 0) proto.h:PERL_CALLCONV HE* Perl_hv_iternext_flags(pTHX_ HV *hv, I32 flags) #### /* file Foo.xs */ #define PERL_NO_GET_CONTEXT #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" MODULE = Foo PACKAGE = Foo SV * foo(hv) HV * hv CODE: hv_store(hv,"newkey", 6, newSVpv("foo", 3),0); #### use blib; use Foo; use Data::Dump qw(dd); $h = {foo => 1, bar => 2}; while (($k,$v) = each %$h) { Foo::foo($h) if $k eq 'foo'; } dd $h; __END__ Use of each() on hash after insertion without resetting hash iterator results in undefined behavior, Perl interpreter: 0x224f010 at foo.pl line 6. { bar => 2, foo => 1, newkey => "foo" }