<div dir="ltr">Hi Folks,<div>I'm using Perl v5.20.0 for sun4-solaris-thread-multi-64 on Solaris 11.</div><div>I have a main thread that reads from disk and adds some values to a Shared Hash and a secondary thread that goes through that Hash, uses some values and delete the used values from the hash.</div><div>Something like this:</div><div><br></div><div><div style="color:rgb(0,0,0);font-family:Verdana;font-size:16.3636360168457px"><font face="Courier New" color="#B20022"><span style="font-size:10pt"># This Thread will run in paralel and check the Memory Hash for completed transactions and do some tricks</span></font></div><div style="color:rgb(0,0,0);font-family:Verdana;font-size:16.3636360168457px"><font face="Courier New" color="#A020F0"><span style="font-size:10pt">my <font color="black">$</font><font color="#A000F0">thr</font><font color="black"> </font><font color="#B22200">= </font><font color="black">threads</font><font color="#B22200">-></font>new<font color="#B22200">( \</font><font color="black">&check_time </font><font color="#B22200">);</font></span></font></div></div><div style="color:rgb(0,0,0);font-family:Verdana;font-size:16.3636360168457px"><span style="color:rgb(160,32,240);font-family:'Courier New';font-size:13.63636302948px">while </span><font color="#B22200" style="font-family:'Courier New';font-size:13.63636302948px">(</font><font color="#A000F0" style="font-family:'Courier New';font-size:13.63636302948px">defined</font><font color="#B22200" style="font-family:'Courier New';font-size:13.63636302948px">(</font><span style="color:rgb(160,32,240);font-family:'Courier New';font-size:13.63636302948px">my </span><font color="black" style="font-family:'Courier New';font-size:13.63636302948px">$</font><font color="#A000F0" style="font-family:'Courier New';font-size:13.63636302948px">line</font><font color="#B22200" style="font-family:'Courier New';font-size:13.63636302948px">=</font><font color="black" style="font-family:'Courier New';font-size:13.63636302948px">$</font><font color="#A000F0" style="font-family:'Courier New';font-size:13.63636302948px">file</font><font color="#B22200" style="font-family:'Courier New';font-size:13.63636302948px">-></font><font color="#A000F0" style="font-family:'Courier New';font-size:13.63636302948px">read</font><font color="#B22200" style="font-family:'Courier New';font-size:13.63636302948px">)) {</font><font face="Courier New" color="#A020F0"><span style="font-size:10pt"><font color="#B22200"><br></font></span></font></div><div style="color:rgb(0,0,0);font-family:Verdana;font-size:16.3636360168457px"><font color="#B22200" style="font-family:'Courier New';font-size:13.63636302948px">    </font><font color="#A020F0" style="font-family:'Courier New';font-size:13.63636302948px">my </font><font style="font-family:'Courier New';font-size:13.63636302948px">@</font><font color="#A000F0" style="font-family:'Courier New';font-size:13.63636302948px">transaction_details</font><font style="font-family:'Courier New';font-size:13.63636302948px"> </font><span style="color:rgb(178,34,0);font-family:'Courier New';font-size:13.63636302948px">: </span><font style="font-family:'Courier New';font-size:13.63636302948px">shared</font><span style="color:rgb(178,34,0);font-family:'Courier New';font-size:13.63636302948px">;</span></div><div style="color:rgb(0,0,0);font-family:Verdana;font-size:16.3636360168457px"><span style="color:rgb(178,34,0);font-family:'Courier New';font-size:13.63636302948px">.</span></div><div style="color:rgb(0,0,0);font-family:Verdana;font-size:16.3636360168457px"><span style="color:rgb(178,34,0);font-family:'Courier New';font-size:13.63636302948px">.</span></div><div style="color:rgb(0,0,0);font-family:Verdana;font-size:16.3636360168457px"><span style="color:rgb(178,34,0);font-family:'Courier New';font-size:13.63636302948px">.</span></div><div style="color:rgb(0,0,0);font-family:Verdana;font-size:16.3636360168457px"><font color="#A020F0" style="font-family:'Courier New';font-size:13.63636302948px">         </font><font style="font-family:'Courier New';font-size:13.63636302948px">$</font><font color="#A000F0" style="font-family:'Courier New';font-size:13.63636302948px">transactions</font><span style="color:rgb(178,34,0);font-family:'Courier New';font-size:13.63636302948px">{ </span><font style="font-family:'Courier New';font-size:13.63636302948px">$</font><font color="#A000F0" style="font-family:'Courier New';font-size:13.63636302948px">transaction</font><span style="color:rgb(178,34,0);font-family:'Courier New';font-size:13.63636302948px">->{</span><font color="blue" style="font-family:'Courier New';font-size:13.63636302948px">"RequestId"</font><span style="color:rgb(178,34,0);font-family:'Courier New';font-size:13.63636302948px">} } = \</span><font style="font-family:'Courier New';font-size:13.63636302948px">@</font><font color="#A000F0" style="font-family:'Courier New';font-size:13.63636302948px">transaction_details</font><span style="color:rgb(178,34,0);font-family:'Courier New';font-size:13.63636302948px">;</span><span style="color:rgb(178,34,0);font-family:'Courier New';font-size:13.63636302948px"><br></span></div><div style="color:rgb(0,0,0);font-family:Verdana;font-size:16.3636360168457px"><span style="color:rgb(178,34,0);font-family:'Courier New';font-size:13.63636302948px">}</span><span style="color:rgb(178,34,0);font-family:'Courier New';font-size:13.63636302948px"><br></span></div><div><font color="#A020F0" style="font-family:'Courier New';font-size:13.63636302948px">sub </font><span style="color:rgb(0,0,0);font-family:'Courier New';font-size:13.63636302948px">check_time</span><font color="#B22200" style="font-family:'Courier New';font-size:13.63636302948px">() {</font><br></div><div><div style="color:rgb(0,0,0);font-family:Verdana;font-size:16.3636360168457px"><font face="Courier New" color="#B22200"><span style="font-size:10pt"><font color="#A020F0">        while </font>(<font color="#A02000">1</font>) {</span></font></div><div style="color:rgb(0,0,0);font-family:Verdana;font-size:16.3636360168457px"><font face="Courier New" color="#B22200"><span style="font-size:10pt">        {</span></font></div><div style="color:rgb(0,0,0);font-family:Verdana;font-size:16.3636360168457px"><font face="Courier New" color="#B22200"><span style="font-size:10pt">             <font color="#A020F0">foreach my </font><font color="black">$</font><font color="#A000F0">key</font><font color="black"> </font>( <font color="#A000F0">keys</font>(<font color="black">%</font><font color="#A000F0">transactions</font>) ) {</span></font></div></div><div style="font-family:Verdana;font-size:16.3636360168457px"><div style="font-size:16.3636360168457px"><font face="Courier New"><span style="font-size:10pt"><font color="#000000">                  doSomeMagic( </font><font color="black" style="color:rgb(0,0,0)">$</font><font color="#A000F0" style="color:rgb(0,0,0)">transactions</font><font color="#000000">{</font><font color="black" style="color:rgb(0,0,0)">$</font><font color="#A000F0" style="color:rgb(0,0,0)">key</font><font color="#000000">} );</font></span></font></div><div style="color:rgb(0,0,0);font-size:16.3636360168457px"><font face="Courier New"><span style="font-size:10pt">                  <font color="#A000F0">delete</font><font color="#B22200">(</font>$<font color="#A000F0">transactions</font><font color="#B22200">{</font>$<font color="#A000F0">key</font><font color="#B22200">});</font></span></font></div><div style="color:rgb(0,0,0);font-size:16.3636360168457px"><font face="Courier New" color="#B22200"><span style="font-size:10pt">                  </span></font><span style="color:rgb(178,0,34);font-size:10pt;font-family:'Courier New'"># Abandoning the Foreach Loop as I've changed the %transactions memory map</span></div><div style="color:rgb(0,0,0);font-size:16.3636360168457px"><font face="Courier New"><span style="font-size:10pt">                  <font color="#A020F0">last</font><font color="#B22200">;</font></span></font></div><div style="color:rgb(0,0,0);font-size:16.3636360168457px"><font face="Courier New" color="#B22200"><span style="font-size:10pt">              }</span></font></div><div style="color:rgb(0,0,0);font-size:16.3636360168457px"><font face="Courier New" color="#B22200"><span style="font-size:10pt">              sleep(1);</span></font></div><div style="color:rgb(0,0,0);font-size:16.3636360168457px"><span style="color:rgb(178,34,0);font-family:'Courier New';font-size:13.63636302948px">      }</span><font face="Courier New" color="#B22200"><span style="font-size:10pt"><br></span></font></div><div style="color:rgb(0,0,0);font-size:16.3636360168457px"><span style="color:rgb(178,34,0);font-family:'Courier New';font-size:13.63636302948px">}</span><span style="color:rgb(178,34,0);font-family:'Courier New';font-size:13.63636302948px"><br></span></div></div><div><div><br></div>-- </div><div>The code works but the warning:</div><div><br></div><div>Use of each() on hash after insertion without resetting hash interator results in undefined behavior</div><div><br></div><div>Is flooding the logs - I've tried to set "no warnings"  or create a copy of %transactions and interact with it instead of %transaction itself but no luck so far. </div><div><br></div><div>Any ideas?</div><div><div dir="ltr"><br><div>Regards,</div><div><br></div><div><div style="color:rgb(136,136,136)"><span style="color:rgb(102,102,102)">Alexandre Andrade | APM Consultant | Ecetera</span><br></div><font size="1" color="#666666"><a href="mailto:alexandre.andrade@ecetera.com.au" style="color:rgb(17,85,204)" target="_blank">alexandre.andrade@ecetera.com.au</a> | M: +61 41307 1370<div><br>Helping rid the World  of badly behaving Apps by investigating my Customers problems and finding solutions to make things work faster and better. <br>Connect to Ecetera on <a href="http://www.linkedin.com/company/ecetera" style="color:rgb(17,85,204)" target="_blank">LinkedIn</a>, <a href="http://www.twitter.com/#!/EceteraAU" style="color:rgb(17,85,204)" target="_blank">Twitter</a><br><br><br></div></font></div><div><p style="margin:0px"></p><p style="margin:0px"></p></div></div>
</div></div>