sub mergedHashKeys{ my( $r1, $r2 ) = @_; my %h = ( %{ $r1 }, %{ $r2 } ); return [ keys %h ]; };; $hash1 = { common_key => 'foo', hash1_specific_key => 'some value' };; $hash2 = { common_key => 'bar', hash2_specific_key => 'some other value' };; pp mergedHashKeys( $hash1, $hash2 );; ["hash2_specific_key", "common_key", "hash1_specific_key"]