my %nxt;
my %prev;
my $prv;
my $first;
for (sort { $a <=> $b } keys %hash) {
$first ||= $_;
if (defined $prv) {
$nxt{$prv} = $_;
$prev{$_} = $prv;
}
$prv = $_;
}
$nxt{$prv}=$first;
$prev{$first}=$prv;
In reply to Re: Re: Finding Previous and Next in a HASH
by turnstep
in thread Finding Previous and Next in a HASH
by skazat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |