in reply to saving the key of a hash

Is this what you want?
foreach my $variable (keys %hash){ my $value = $hash{$variable}; print "$variable\t$value\n"; }