Hi, Cris Charley posted me the following tip:
I did this with the code below, but there are even better solutions in the attachment to this post. They are from MJD quiz of the week #6. However, they don't meet the requirement that only 2 numbers in sequence should be reported seperately :-) I mailed to you because for some reason I couldn't mail the group! Could you please post?!! #!/usr/bin/perl use strict; use warnings; my $kommalist ="-3,-2,-1,-5,-4,20,22,23,24,25,27,28,31,32,33,50"; my @nums = split /,/, $kommalist; my $i = 0; my @result; while ($i < @nums) { my $start_idx = $i; my $begin = $nums[$i]; 1 while (++$i < @nums && ++$begin == $nums[$i]); if ($i - $start_idx <= 2) { push @result, $nums[$_] for $start_idx .. $i-1; } else { push @result, "$nums[$start_idx]..$nums[$i-1]"; } } my $result = join ",", @result; print $result; ... Thanks to everyone else how help me. Götz -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]