On Mon, 4 Feb 2002 11:30:08 +0900, Nobumi Iyanaga wrote:
source:
>(343, 512, 71, 562, 346, 345, 513, 561, 563, 343, 513, 549, 562, 71, 76,
>345, 510, 563)
result:
>71, 71, 76, 343, 343, 345, 345-346, 510, 512-513, 513, 549, 561-562,
>562-563, 563
>while what I would expect is:
>
>71, 76, 343, 345-346, 510, 512-513, 549, 561-563
>
>I am sorry I am unable to figure out how to fix these glitches.
Dead easy. How do you remove duplicates in Perl? This is a FAQ: by
populating a hash, and extracting the hash keys.
For example:
my %check;
for (343, 512, 71, 562, 346, 345, 513, 561, 563, 343, 513, 549,
562, 71, 76, 345, 510, 563) {
$check{$_} = 1;
}
my $string = join ", ",sort {$a<=>$b} keys %check;
...
You can take it from here.
--
Bart.