in reply to Formatting

Just off the top of my head, could you not do something like this (untested code):

#!/usr/bin/perl -w use strict; my $infilename = 'blah.dat'; my $outfilename = 'blah.out'; my (%data); open(DF, $infilename) or die("Can't open $infilename for input: $!\n"); while (my $line = <DF>) { chomp($line); my @parts = split(/\s/, $line, 2); push(@{$data{$parts[0]}}, $parts[1]); } close(DF); open(OUTF, '>' . $outfilename) or die("Can't open $outfile for output: $!\n"); foreach my $k (sort(keys(%data))) { print OUTF "<p>", join(', ', @{$data{$k}}), "</p>\n"; } close(OUTF);

Basically, the idea would be to push the data into an array, then join them as you liked.

Hope that helps....