in reply to Algorithmic hash bug.

I guess that you want something like this:
use strict; use warnings; my $valueM = 'myvalue'; my $hashref; $$hashref{mainKey}{$valueM}{key} = 'value';

or
my %hash; $hash{key} = 'value'; ...