in reply to Strange Hash Problem

It appears that there is something strange with the hash. If I do something like this :
$vHash{"101010"}{"S0"} = "text"; $vHash{"101010USED"}{"S0"} = "text"; if (!exists($vHash{"101010"}{"S0"}{"SYSTEM"})) { $vHash{"101010"}{"S0"}{"SYSTEM"} = "TEXT"; print "First<br>"; } if (!exists($vHash{"101010USED"}{"S0"}{"SYSTEM"})) { $vHash{"101010USED"}{"S0"}{"SYSTEM"} = "TEXT"; print "Second<br>"; }
I only get First printed. If I happen to take the USED in the second if statement and change it to USED101010 and then retry running it I get First and Second print out. Does Perl just look at the first n characters in a hash? Does it see it starts with numbers and then only takes the numbers up until a non-numeric value? Does anyone have an idea to what is happening? Thanks in advance for any help.

Replies are listed 'Best First'.
Re^2: Strange Hash Problem
by ikegami (Patriarch) on Jul 29, 2009 at 23:36 UTC

    Does Perl just look at the first n characters in a hash?

    No.

    Does it see it starts with numbers and then only takes the numbers up until a non-numeric value?

    No.

    Does anyone have an idea to what is happening?

    Yes. You treat the string "text" as a hash reference. Using use strict; use warnings; would have caught this.