C:\Documents and Settings\my\Desktop>perl test.pl 0 ==== zero 1 ==== one 2 ==== three 3 ==== four 4 ==== four #### #!/usr/bin/perl use warnings; use strict; my %hash = ( "0" => "zero", "1" => "one", "2" => "two", "3" => "three", "4" => "four" ); delete $hash{2}; my $num = "-1"; foreach (sort keys %hash) { $num++; my $value = $hash{$_}; $hash{$num} = $value; } foreach (sort keys %hash) { print "$_ ==== $hash{$_}\n"; }