Hello Bart and Paul,

I used your script extensively, and I found some minor problems.  If, for 
example I hava a list of page numbers like this:

(343, 512, 71, 562, 346, 345, 513, 561, 563, 343, 513, 549, 562, 71, 76, 
345, 510, 563)

the script:

my @list=(343, 512, 71, 562, 346, 345, 513, 561, 563, 343, 513, 549, 562, 
71, 76, 345, 510, 563);
my $string = join ", ",sort {$a<=>$b} @list;
$string =~ s/(\d+), (?=(\d+))/($2-$1==1)?"$1-":"$1, "/eg;
$string =~ s/(-\d+)+/$1/g;
print $string, "\n";

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.  Could you 
please give me any ideas?

Thank you again in advance for your help!

Best regards,

Nobumi Iyanaga
Tokyo,
Japan

Reply via email to