X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=quacks-ingredients-counts;h=5c20fc8ffa5c689d96c2941494f76c906f8d4b0e;hb=94626a602f2bb79103554cf3a6ddd5304963bf90;hp=15e6bd8c52ad5325d053964c85a90375de365c02;hpb=4cf336ec8769a245df0938c73d926066c0551d3d;p=reprap-play.git diff --git a/quacks-ingredients-counts b/quacks-ingredients-counts index 15e6bd8..5c20fc8 100755 --- a/quacks-ingredients-counts +++ b/quacks-ingredients-counts @@ -36,10 +36,10 @@ foreach my $nspots (qw(1 2 3 4)) { foreach my $i (0..$#names) { $_ = $l[$i] || '0+0'; $_ ||= 0; - m/\+/; + m/\+/ or die "$which $nspots ?"; $count{$names[$i]}{$nspots} = - $which eq 'Both' ? $` + $' : + $which eq 'All' ? $` + $' : $which eq 'Base' ? $` : $which eq 'Witches' ? $' : die "$which ?"; @@ -57,9 +57,10 @@ our $max_nrows=0; our $max_rowsz=0; sub wrtoplevel () { - print "module $name(){ ////toplevel\n"; my $cs = $count{$name}; my $total = 0; $total += $_ foreach values %$cs; + return unless $total; + print "module ${which}_$name(){ ////toplevel\n"; my $rowsz = ceil(sqrt($total)); my $nrows = ceil($total / $rowsz); $total_count += $total; @@ -67,8 +68,8 @@ sub wrtoplevel () { $max_nrows = $nrows if $nrows > $max_nrows; $max_rowsz = $rowsz if $rowsz > $max_rowsz; my $ix = 0; - printf "// %-10s total=%2d rowsz=$rowsz nrows=$nrows\n", - "$name", $total; + printf "// %s %-10s total=%2d rowsz=$rowsz nrows=$nrows\n", + $which, "$name", $total; foreach my $nspots (sort keys %$cs) { my $c = $cs->{$nspots}; print <error and die $!; __DATA__ -White Green Blue Red Yellow Purple Black Orange -20+6 15+10 14+8 12+6 13+6 15+8 18+8 20+12 -8+3 10+5 10+5 8+5 6+5 -4+2 +White Green Blue Red Yellow Purple Black Orange WhiteSpare +20+6 15+10 14+8 12+6 13+6 15+8 18+8 20+12 1+0 +8+3 10+5 10+5 8+5 6+5 1+0 +4+2 1+0 13+5 10+5 10+5 10+5