I'd suggest using a counter variable rather than localtime (did you mean time?).
my $count = 0; my $test; unless ( exists $hash{$test} ) { $hash{$test} = $count++; }
This way, you can be sure you don't have duplicate values in the hash, even if you insert two elements at the same second.
To do the sorting, you'd need to do this:
sort { $hash{$a} <=> $hash{$b} } keys %hash;
In reply to Re^3: Is there an easy way to assign guaranteed unique values to a simple array without looping through whole array?
by kyle
in thread Is there an easy way to assign guaranteed unique values to a simple array without looping through whole array?
by memnoch
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |