a($_) while ; for (sort keys %h){ print "$_: my address is $h{$_}\n"; print "last: $h{$_}{'a'} >>> $h{$_}{'a'}{'c'}\n"; print "next: $h{$_}{'b'} >>> $h{$_}{'b'}{'c'}\n\n"; } sub a { chomp; $t = shift; $h{$t}{'a'} = $l; $h{$t}{'c'} = $t; $$l{'b'} = $h{$t}; $l = $h{$t}; } __DATA__ a b c d e