use warnings; use strict; use Data::Dump qw(dump); my %h = ( 1 => { 1 => 'foo', 2 => 'bar', }, 2 => [], 3 => 'foo', ); clear(\%h); sub clear{ my $ref = shift; %$ref->{1} = (); # { 1 => undef, 2 => [], 3 => "foo" } %{$ref->{1}} = (); # { 1 => {}, 2 => [], 3 => "foo" } } print dump \%h;