05/10/09 16:03:48
>>266 俺頭悪いからこんなソースしか書けんわ。すまん。
#!/usr/bin/perl
$|=1;
$file = <STDIN>;
chomp $file;
open(FH, $file);
while (<FH>) {
chomp;
push @vals, $_;
}
close(FH);
$head = $vals[0];
$buf .= $vals[0];
shift @vals;
foreach $val (@vals) {
if($head + 1 == $val){
$buf .= '-';
$head = $val;
next;
}
if($val > $head + 1){
$buf .= $head.','.$val;
$head = $val;
next;
}
}
$buf =~ tr/-//s;
print $buf;