%hash = qw/a 1 b 2 c 3 d 4 e 5/; for $key (keys %hash) { print 'Key:', $key, '=', $hash{ $key }, "\n" } Key: e = 5 Key: c = 3 Key: a = 1 Key: b = 2 Key: d = 4 #### %hash = qw/a 5 b 4 c 3 d 2 e 1/; for $key (sort keys %hash) { print $hash{ $key }, "\n" } 5 4 3 2 1 #### perl> %hash = qw/a 5 b 4 c 3 d 2 e 1/; for $val (values %hash) { print $val, "\n" } 1 3 5 4 2 for $val ( sort values %hash ) { print $val, "\n" } 1 2 3 4 5