http://www.perlmonks.org?node_id=314711


in reply to Re: Deleting undef values from a hash
in thread Deleting undef values from a hash

I think that you'll have a hard time finding that documented. ;-) (Though I have a pretty good idea why it works.)

I also wouldn't want to trust it across Perl versions. That seems very specific to perl5, and I would not plan on that specific optimization finding its way into Ponie for instance.

  • Comment on Re: Re: Deleting undef values from a hash

Replies are listed 'Best First'.
Re: Re: Re: Deleting undef values from a hash
by ysth (Canon) on Dec 15, 2003 at 00:04 UTC
    It should be ok for perl5, though. The division of responsibilities between hv_delete_* and pp_delete pretty much require that it work. hv_delete_* will return null if the key didn't exist, which pp_delete will replace with the immortal undef value. If the key did exist, hv_delete_* will return the value (even undef) in a different sv.

    It's obviously better practice to check exists in the first place, outside of obfuscation and golf.