in reply to Strange Behaviour of Two Hashes

Strange? I cannot reproduce your reported behaviour. This is the output I get from your code:

P:\test>457797 $VAR1 = { 'S1' => 'C-D', 'S2' => 'C-D', 'S4' => 'CID', 'S3' => 'CAD' }; From LOOP $VAR1 = { 'S1' => 'C-D', 'S2' => 'C-D', 'S4' => 'CID', 'S3' => 'CAD' };

Is that what you are expecting?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.

Replies are listed 'Best First'.
Re^2: Strange Behaviour of Two Hashes
by monkfan (Curate) on May 17, 2005 at 15:14 UTC
    Hi BrowserUk,
    Thanks for answering. As I have commented inside the code. you will see the problem, only after you move those three lines after the "foreach(@test)" block. Please try it.
    It should print this:
    $VAR1 = {}; From LOOP $VAR1 = {};
    Regards,
    Edward

      Hmmm. I copied them this time rather than moved them which explains the error messages:

      P:\test>457797 "my" variable $seq masks earlier declaration in same scope at P:\test\ +457797.pl line 37. "my" variable %alignment masks earlier declaration in same scope at P: +\test\457797.pl line 38. $VAR1 = { 'S1' => 'C-D', 'S2' => 'C-D', 'S4' => 'CID', 'S3' => 'CAD' }; $VAR1 = { 'S1' => 'C-D', 'S2' => 'C-D', 'S4' => 'CID', 'S3' => 'CAD' }; From LOOP $VAR1 = { 'S1' => 'C-D', 'S2' => 'C-D', 'S4' => 'CID', 'S3' => 'CAD' };

      But I still don't see the problem?


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.