s{^}{// }mg;
our $name;
+our $total_count;
+our $max_nrows=0;
+our $max_rowsz=0;
sub wrtoplevel () {
print "module $name(){ ////toplevel\n";
my $total = 0; $total += $_ foreach values %$cs;
my $rowsz = ceil(sqrt($total));
my $nrows = ceil($total / $rowsz);
+ $total_count += $total;
+ $max_nrows = $nrows if $nrows > $max_nrows;
+ $max_rowsz = $rowsz if $rowsz > $max_rowsz;
my $ix = 0;
print "// total=$total, rowsz=$rowsz, nrows=$nrows\n";
foreach my $nspots (sort keys %$cs) {
wrtoplevel();
}
+print <<END;
+// total_count=$total_count
+// max_rowsz=$max_rowsz max_nrows=$max_nrows
+END
+
STDOUT->error and die $!;
__DATA__