foreach $key(keys %tagcorpus){ print "\n$key"; return($key); } #### undef %h; @h{'a'..'m'}=1..13; print each %h, ' - ' for 1..7; # Gives "e 5 - a 1 - m 13 - d 4 - j 10 - l 12 - c 3 -" # The first seven key/value pairs in some order print each %h, ' - ' for 1..7; # Gives "k 11 - h 8 - b 2 - g 7 - f 6 - i 9 - -" # The last 6 + an empty pair to indicate the end of the list undef %h; @h{'a'..'m'}=1..13 print each %h, ' - ' for 1..7; # Gives "e 5 - a 1 - m 13 - d 4 - j 10 - l 12 - c 3 -" The first seven as before @h{'n'..'z'} = 14..26; # Now modify the hash by adding some new stuff # Now continue iterating them from whre we were before print each %h, ' - ' for 1..7; # Gives "p 16 - k 11 - h 8 - g 7 - f 6 - t 20 - i 9 -" # Looks good, no empty pair so it knows there are more # and nothing is duplicated... print each %h, ' - ' for 1..7; # Print the next batch # "e 5 - n 14 - v 22 - m 13 - s 19 - l 12 - c 3 -" Whoops!! # Even though we haven't had the empty pair to indicate the of the list # Were starting to see some elements being repeated. # We've already seen e, m, j, l & c in the first batch. print each %h, ' - ' for 1..7; # Gives "p 16 - b 2 - q 17 - z 26 - o 15 - - w 23 -" NOTE the empty pair! # Now we have reached the end of the list, wrapped and are starting again # But the first one we get this time is 'w' rather than 'e' that we got first time # And it isn't 'a' in either case.