http://qs321.pair.com?node_id=627542


in reply to right use of a hash table

steph_bow,
You are initializing a scalar $M4 yet you are using it like a hash %M4 with your $M4{$target} code. You are saying give me the scalar ($) in the %M4 hash at the key $target, whatever that happens to be. Though a hash is initialized with the % symbol it contains scalars as values. Thus when you refer to an element in the hash (be it a number, string, character or reference to something else) you call it in its resultant context, in this case a scalar (though you could also pull out an array or another hash if that is what you stored a reference to in there) . If you want to use a scalar as a reference to an anonymous hash you would need to change your assignments to utilize the -> so $M4_compteur{$target} becomes $M4_compteur->{$target} for both assignment and retrieval. Does that make sense?
perldata, perldsc and perlref might all be of help. Happy reading!

-InjunJoel
"I do not feel obliged to believe that the same God who endowed us with sense, reason and intellect has intended us to forego their use." -Galileo