use strict; my @hashes = ({}) x 10; $hashes[$_]{$_} = 1 foreach (0 .. 9); foreach (0 .. 9) { print join(':', keys %{$hashes[$_]}), "\n" }