open (DB1,"logfile.log") or die("There was a problem opening the file."); while ($entry=) { chomp $entry; @fields = sort { $a cmp $b } split /\t/, $entry; #@fields=split(/ /,$entry); #chomp @fields; foreach $entry (@fields){ $_ =~ s/\n/\,/; }