sub do_stuff { +-----+ +------------------+ $href --->| a: --->| status: "OK" | +-----+ +------------------+ my $hash = shift; +-----+ +------------------+ $href --->| a: --->| status: "OK" | $hash / +-----+ +------------------+ my $hash2 = freeze($hash); +-----+ +------------------+ $href --->| a: --->| status: "OK" | $hash / +-----+ +------------------+ +--------------------------------+ $hash2 = | Frozen image of | | +-----+ +------------------+ | | | a: --->| status: "OK" | | | +-----+ +------------------+ | +--------------------------------+ $hash->{'a'}->{'status'} = "NOT OK"; +-----+ +------------------+ $href --->| a: --->| status: "NOT OK" | $hash / +-----+ +------------------+ +--------------------------------+ $hash2 = | Frozen image of | | +-----+ +------------------+ | | | a: --->| status: "OK" | | | +-----+ +------------------+ | +--------------------------------+ $hash = thaw($hash2); +-----+ +------------------+ $href --->| a: --->| status: "NOT OK" | +-----+ +------------------+ +--------------------------------+ $hash2 = | Frozen image of | | +-----+ +------------------+ | | | a: --->| status: "OK" | | | +-----+ +------------------+ | +--------------------------------+ +-----+ +------------------+ $hash --->| a: --->| status: "OK" | +-----+ +------------------+ print "IN SUB: " . $hash->{'a'}->{'status'} . "\n"; return 0; } #### sub do_stuff { my $hash = dclone(shift); $hash->{'a'}->{'status'} = "NOT OK"; print "IN SUB: " . $hash->{'a'}->{'status'} . "\n"; } #### sub do_stuff { +-----+ +------------------+ $href --->| a: --->| status: "OK" | +-----+ +------------------+ my $hash = dclone(shift); +-----+ +------------------+ $href --->| a: --->| status: "OK" | +-----+ +------------------+ +-----+ +------------------+ $hash --->| a: --->| status: "OK" | +-----+ +------------------+ $hash->{'a'}->{'status'} = "NOT OK"; +-----+ +------------------+ $href --->| a: --->| status: "OK" | +-----+ +------------------+ +-----+ +------------------+ $hash --->| a: --->| status: "NOT OK" | +-----+ +------------------+ print "IN SUB: " . $hash->{'a'}->{'status'} . "\n"; return 0; }