http://www.perlmonks.org?node_id=1222946


in reply to goto HACK

use strict; use warnings; use Data::Dumper; my @times = qw(1000 1000 1000 1010 1010 1010); my $hash = {}; for my $time (@times) { $time++ while exists $hash->{$time}; $hash->{$time}->{one} = 1; $hash->{$time}->{two} = 2; } print Dumper $hash;
Note that $time++ modifies the element of @times, since 'for' makes $time an alias of each element. If that's undesirable, copy $time to another var at the top of the loop, and use that instead.

Dave.