use strict; use warnings; use Devel::Peek qw(Dump); my $s = 'AAAAAAAAAAAAAAA'; my %hash = map {$s++ => 1} 1 .. 2; print "before:\n"; Dump \%hash; open my $fh, '>', 'j1.txt' or die $!; for my $key (keys %hash) { print $fh "$key $hash{$key}\n"; } print "after:\n"; Dump \%hash;