in reply to Forcing dereference

What you're really copying is a reference to the secondary data structure, but what is being referenced is still the same thing. You need to make a deep copy. Heres one way to do it:
use Storable qw(dclone); my $fee->{'SOMETHING_02'} = dclone($foo->{'SOMETHING_01'});
You'll probably want to read about the Storable module at cpan.

Replies are listed 'Best First'.
Re^2: Forcing dereference
by radiantmatrix (Parson) on Oct 15, 2004 at 18:53 UTC

    Exactly right. Let me illustrate what is happening. Your data structure looks like (simplified):

    $foo = { 'SOMETHING_01' => {'CLASS' => [ {'VALUE' => 'BUBBLE' } ] } }
    Let's do a little analysis, assuming $foo retains its value:
    $bar = $foo->{SOMETHING_01}; # $bar is hash reference $caz = %{$foo->{SOMETHING_01}; # $caz is a hash print $caz{'CLASS'}; # 'ARRAY(...)' - an array reference print $caz{'CLASS'}->[0]; # 'HASH(...)' - a hash reference
    Note that when you copy a reference, you aren't copying the data -- you're making a new reference to the same data. By using the deep-copy method of the parent, you copy the data contained in the reference instead of the reference itself.

    radiantmatrix
    require General::Disclaimer;