if (defined($hash{$key}) { $hash{$key} ++; } else { $hash{$key} = 1; } #### $hash{$key}++; #### %hash = ("www.yahoo.com", 10, "www.google.com", 2000); foreach (keys %hash) { $rev_hash{$hash{$_}} = $_; } foreach (sort keys %rev_hash) { print "$rev_hash{$_} appears: $_ time(s)\n"; } #### %hash = ( www.yahoo.com => 10, www.google.com => 2000, ); for ( sort { $hash{$a} <=> $hash{$b} } keys %hash ) { print "$_ appears: $hash{$_} time(s)\n"; }