use strict; use Data::Dumper; my %hash = qw/ A 1 B 2 /; print 'Before sub:'.Dumper(\%hash); modify_hash(\%hash); print 'After sub:'.Dumper(\%hash); sub modify_hash{ my $h_ref = shift; $h_ref->{C} = '3'; $h_ref->{D} = '4'; %{$h_ref}->{E} = '5'; # this is what it's doing $$h_ref{F} = '6'; # you could do this too } #### Before sub:$VAR1 = { 'A' => '1', 'B' => '2' }; After sub:$VAR1 = { 'F' => '6', 'A' => '1', 'B' => '2', 'C' => '3', 'D' => '4', 'E' => '5' };