in reply to Dereferencing Mystery

  1. You shouldn't use Switch.pm, it has subtle bugs.
  2. What's the switch for here anway, all you're doing is execute one "case" after the other, there's no fall-through or anything that requires this execution out of a standard for-loop.
  3. Running this codes gives the following output:
0 --HASH(0x82bfd04) Data_Directories_fetch 1 --HASH(0x828b9a8) Data_Directories_erase 2 --HASH(0x82bbf40) Program_fetch 3 --HASH(0x82bfcbc) Program_erase 4 --HASH(0x82bbec8) Configuration_and_Table_Files_erase 5 --HASH(0x815b734) Configuration_and_Table_Files_fetch 6 --HASH(0x82bbee0) Create_Database 7 --HASH(0x82bbe38) Load_Database HASH(0x82bbf40) Result: HASH(0x82bbf40)

Loading some values into the Program_fetch hash first gives:

0 --HASH(0x82bc21c) Data_Directories_fetch 1 --HASH(0x82bfd00) Data_Directories_erase 2 --HASH(0x8160c8c) Program_fetch 3 --HASH(0x82bc0f0) Program_erase 4 --HASH(0x82bfce8) Configuration_and_Table_Files_erase 5 --HASH(0x815b728) Configuration_and_Table_Files_fetch 6 --HASH(0x82bc12c) Create_Database 7 --HASH(0x82bfd84) Load_Database HASH(0x8160c8c) 1 => 2 3 => 4 Result: HASH(0x8160c8c) 1 => 2 3 => 4

Which is exactly what I'd expect. What are you expecting to see?


There are ten types of people: those that understand binary and those that don't.

Replies are listed 'Best First'.
Re^2: Dereferencing Mystery
by blankdon (Initiate) on Jan 08, 2006 at 05:15 UTC
    My second hash reference points to the same address as the first but, unlike yours, doesn't print out the values. The second is a DBM record on the drive.

    So, I think it's not resolved?
Re^2: Dereferencing Mystery
by Anonymous Monk on Jan 08, 2006 at 01:14 UTC
    The switch is just a way to associate the hash addresses with a descriptive string. Perhaps not the bast way but the mystery is that I get the following.
    The loops are referencing the same hash but what I can't explain is why only the first loop works?

    0 --HASH(0x18b73bc) Data_Directories_fetch 1 --HASH(0x18a50f0) Data_Directories_erase 2 --HASH(0x18b7518) Program_fetch 3 --HASH(0x18b74e8) Program_erase 4 --HASH(0x555250) Configuration_and_Table_Files_erase 5 --HASH(0x555280) Configuration_and_Table_Files_fetch 6 --HASH(0x18b8224) Create_Database 7 --HASH(0x18b8254) Load_Database HASH(0x18b7518) /reba/shlib => Y /airreba/procs => Y /xcape/bin => Y /reba/bin => Y /airreba/tables => Y /reba/onetime => Y /xcape/bin_util => Y /reba/perlib => Y Result: HASH(0x18b7518)

    Edit: g0n - code tags

Re^2: Dereferencing Mystery
by Anonymous Monk on Jan 08, 2006 at 01:27 UTC
    Ok! That seems to explaint it!!! Gee I fool feelish! Thanks Much!