#!/usr/bin/perl use strict; use threads; use threads::shared; my %outer :shared; $outer{inner} = &share({}); %{$outer{inner}} = map { $_ => $_ } 'a'..'z'; ################################################################# print "By taking a reference first...\n"; my $iter = 0; { my $ref = $outer{inner}; while ($iter++ < 10) { last unless (my ($k, $v) = each %$ref); print "$k\n"; } } print "...and so on\n\n"; ################################################################# print "By de-ref the shared hash-of-hashes each time...\n"; $iter = 0; while ($iter++ < 10) { last unless (my ($k, $v) = each %{$outer{inner}}); print "$k\n"; } print "...and so on\n"; #### By taking a reference first... w r a x d j y u k h ...and so on By de-ref the shared hash-of-hashes each time... w w w w w w w w w w ...and so on