#!/usr/bin/perl -l use strict; use warnings; my %comment; #comment for each bug id ; #skip header line while(){ chomp; #the 4 in the split below ignores all comma in the comment text my (undef, $bugid, $date, $body) = split(/,/, $_, 4); $comment{$bugid} .= "$date $body "; } while (my ($id, $comment) = each %comment){ print "$id, $comment"; } __DATA__ CommentId, BugId, Date, CommentBody 1023,9555,03/06/2008,This is the body 1024,9555,03/07/2008,This is the body 1025,9555,03/08/2008,This is the body