#! /usr/bin/perl -w open ( IN, "$ARGV[0]" ); $first = $ARGV[1]; $last = $first; $list = $first; $new = $first; while ( ) { chomp; if ($_ == $first) { $last = $_; next; } if ( $_ == $last + 1 ) { $new = $list."-".$_; $last = $_; } else { $list = $new.",".$_; $new = $list; $last = $_; } } print " $list\n";