Hi Eilly , Thanks for your inputs. I have puts small portion of the complete code to replicate scenerio. I have used dumper and checked the results before and after execution of the loop and observed that even elseif condition was not satisfied, that loop got executed. I have modified my code as below to print initial and final value of the hash before and after the loop.
foreach my $net(@netLst){ //For debug foreach my $key_net (keys %{$moduleRef->{modRef}{$moduleName +}{ioRef}}) { print "IN: moduleName = $moduleName; net = $key_net; indx + = $moduleRef->{modRef}{$moduleName}{ioRef}{$key_net}{indx}\n"; } if($net =~ /\'/) {next;} elsif(defined ($moduleRef->{modRef}{$moduleName}{ioRef}{$net}) +) { print "$net is part of hash "; } //For debug foreach my $key_net (keys %{$moduleRef->{modRef}{$moduleName +}{ioRef}}) { print "OUT: moduleName = $moduleName; net = $key_net; ind +x = $moduleRef->{modRef}{$moduleName}{ioRef}{$key_net}{indx}\n"; } }
It Printed output as below.
IN: moduleName = msc_chan_reset; net = ch_rst_l; indx = 2 IN: moduleName = msc_chan_reset; net = data_in; indx = 3 IN: moduleName = msc_chan_reset; net = clk; indx = 0 IN: moduleName = msc_chan_reset; net = rst_l; indx = 1 IN: moduleName = msc_chan_reset; net = data_out; indx = 4 ts_500_gated_clk_buf is hash part of hash OUT: moduleName = msc_chan_reset; net = ch_rst_l; indx = 2 OUT: moduleName = msc_chan_reset; net = data_in; indx = 3 OUT: moduleName = msc_chan_reset; net = clk; indx = 0 OUT: moduleName = msc_chan_reset; net = ts_500_gated_clk_buf; indx = + OUT: moduleName = msc_chan_reset; net = rst_l; indx = 1 OUT: moduleName = msc_chan_reset; net = data_out; indx = 4 ####:
So here even though ts_500_gated_clk_buf was not part of the hash, it executed that loop and here on it added that hash with net ts_500_gated_clk_buf even though it wasn't intended. Thanks, Sandeep

In reply to Re^2: Wrong Results in checking if hash value is defined or not by sandeep.waikar
in thread Wrong Results in checking if hash value is defined or not by sandeep.waikar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.