in reply to reference of hash

$HASH_OF_FLOW->{'$key'} = 'M2';
Single quotes prevent variable interpolation of $key. You probably want:
$HASH_OF_FLOW->{$key} = 'M2';