1/2/2007, 1, 4, 5, 6 1/3/2007, 2, 5, 7, 10 1/5/2007, 5, 6, 8, 11 #### my @previous; while(<>){ chomp; my @current = split /,/, $_; if ( not @previous ) { print join ',', @current[ 1 .. $#current ]; print "\n"; } else { for my $i ( 1 .. ( $#current - 1 ) ) { print $current[$i], '-', $previous[$i], ','; } print $current[-1], '-', $previous[-1], "\n"; @previous = @current; } }