in reply to How can one change the keys of a hash to an alternative set of keys?

See each to iterate thru key/value pairs of a hash.

Copy to new hash in loop with changed key.

update

To answer the tread title, you can't. Keys are immutable. They can be deleted or created but they can't be changed.

Cheers Rolf

PS: Je suis Charlie!

  • Comment on Re: How can one change the keys of a hash to an alternative set of keys?

Replies are listed 'Best First'.
Re^2: How can one change the keys of a hash to an alternative set of keys?
by choroba (Cardinal) on Feb 04, 2015 at 22:18 UTC
    Read also Do not use each.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      IIRC is each safe as long as you don't try to call any routines in the loop!

      Copying to a new hash is hardly a threat.

      Cheers Rolf

      PS: Je suis Charlie!

        IIRC is each safe as long as you don't try to call any routines in the loop!Copying to a new hash is hardly a threat.

        But TheDamian says, sometimes in the future, a more clueless maintainer is going to break it dangerously, so avoid it .... might as well avoid perl