in reply to Hash reference Problem

The result is something like $VAR1->{'1'}{'test2'}.

That's just due to the way Data::Dumper has to represent the data. In order to allow for the feature to be able to recreate the original data structure by eval-ing Data::Dumper's output, it cannot repeatedly expand substructures, because in that case you'd get a new instance of the structure (hash, array,...), instead of a reference to the existing structure.

Try print Dumper $ref_2a, $ref_2b; in VERSION 2, and you'll see that it now also shows

$VAR2 = { '2' => { 'test1' => { '1' => $VAR1->{'1'}{'test1'}, ...

instead of the expanded style you got before

$VAR1 = { '2' => { 'test1' => { '1' => { 'key2' => '2', 'key1' => '1', 'key3' => '3' }, ...

That's because now it has already encountered (and displayed (or created upon eval-ing ...)) the structure referenced by $VAR1->{'1'}{'test1'}.