The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

Name

qbit::Hash - Functions to manipulate hashes.

Functions

hash_transform

Arguments:

  • $hs - hash ref, original hash;

  • $arr - array ref, keys to copy;

  • $transform_hs - hash ref, new keys names.

Return value: hash with new keys names.

 my %new_hash = hash_transform(
     {
         a => 1,
         b => 2,
         c => 3,
         d => 4
     },
     [qw(a c)],
     {
         d => 'e'
     }
 );

 Result:
 %new_hash = (
     a => 1,
     c => 3,
     e => 4
 )

push_hs

Arguments:

  • $h1|%h1 - hash or hash ref, first hash;

  • $h2|%h2 - hash or hash ref, second hash.

Merge second hash into first.