#!/usr/bin/perl

use strict;
use warnings;
use Getopt::Long;

my (%comment,%data);
my $comment='';
while (<>) {
    if (/^\s*(?:#|$)/) {
	$comment .= $_;
    } else {
	my @in=split(/\s+/, $_);
	die "Oops: $in[0] already loaded: was $data{$in[0]} got $_" if $data{$in[0]};
	$data{$in[0]}=$_;
	$comment{$in[0]}=$comment;
	$comment='';
    }
}

foreach my $key (sort {$a cmp $b} keys(%data)) {
    print $comment{$key}, $data{$key};
}
