<?xml version="1.0" encoding="windows-1252"?>
<node id="1011259" title="Re: Syntax explanation required" created="2013-01-02 07:35:06" updated="2013-01-02 07:35:06">
<type id="11">
note</type>
<author id="708738">
LanX</author>
<data>
<field name="doctext">
&lt;i&gt;&gt; &lt;c&gt;my @uniq = keys %{ {%hash1, %hash2} };&lt;/c&gt;&lt;/i&gt;&lt;P&gt;


From inside out:&lt;P&gt;

- First the two hashes are flattened to lists, which are combined to a long list.&lt;P&gt;

- Building a new (anonymous) hashref will eliminate duplicated entries from that hash ¹&lt;P&gt;

- To be able to extract² the [doc://keys] you still need to dereference this ano-hashref with &lt;c&gt;%{..}&lt;/c&gt;. &lt;P&gt;

step by step:&lt;P&gt;

&lt;c&gt;
  DB&lt;111&gt; %hash1= (a=&gt;1,b=&gt;2)
 =&gt; ("a", 1, "b", 2)
 
  DB&lt;112&gt; %hash2= (a=&gt;1,c=&gt;3)
 =&gt; ("a", 1, "c", 3)
 
  DB&lt;113&gt; (%hash1, %hash2)
 =&gt; ("a", 1, "b", 2, "c", 3, "a", 1)
 
  DB&lt;115&gt; + {%hash1, %hash2}
 =&gt; { a =&gt; 1, b =&gt; 2, c =&gt; 3 }
 
  DB&lt;117&gt; %{ {%hash1, %hash2} }
 =&gt; ("c", 3, "a", 1, "b", 2)
 
  DB&lt;118&gt; keys %{ {%hash1, %hash2} }
 =&gt; ("c", "a", "b")
&lt;/c&gt;&lt;P&gt;

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-708738"&gt;
&lt;p&gt;Cheers Rolf
&lt;/div&gt;&lt;/div&gt;&lt;P&gt;

UPDATES:&lt;P&gt;

¹) because repeated keys will be overwritten.&lt;P&gt;

²) at least with older perl-versions, see [Athanasius]' [id://1011266|remark]</field>
<field name="root_node">
1011256</field>
<field name="parent_node">
1011256</field>
</data>
</node>
