comparison materials/parsealloys.pl @ 315:72bf6267e34f misc

Use underlines for multiword material names in plaintext format alloy list.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 30 Dec 2015 06:58:07 +0200
parents 809e2a1c64eb
children a4dff42fc40e
comparison
equal deleted inserted replaced
314:7615bf7f980f 315:72bf6267e34f
28 { 28 {
29 die("$0: Invalid operation mode '$mode'.\n"); 29 die("$0: Invalid operation mode '$mode'.\n");
30 } 30 }
31 31
32 32
33 sub ul($)
34 {
35 my $tmp = $_[0];
36 $tmp =~ s/ /_/g;
37 return $tmp;
38 }
39
40
33 ### 41 ###
34 ### Parse data from input, ignoring fumbled alloys 42 ### Parse data from input, ignoring fumbled alloys
35 ### 43 ###
36 my %data = (); 44 my %data = ();
37 my $fumble = 0; 45 my $fumble = 0;
47 { 55 {
48 print STDERR "Ignoring fumbled combo $_[1] + $_[2] = $_[0]\n"; 56 print STDERR "Ignoring fumbled combo $_[1] + $_[2] = $_[0]\n";
49 } 57 }
50 $fumble = 0; 58 $fumble = 0;
51 } 59 }
60
52 61
53 while (<STDIN>) { 62 while (<STDIN>) {
54 chomp; 63 chomp;
55 if (/^You mix ([a-z ]+?) and ([a-z ]+?) and create a quantity of (.+?)\.?$/) 64 if (/^You mix ([a-z ]+?) and ([a-z ]+?) and create a quantity of (.+?)\.?$/)
56 { 65 {
202 211
203 foreach my $min1 (@{$$Materials::matByType{$type}}) 212 foreach my $min1 (@{$$Materials::matByType{$type}})
204 { 213 {
205 foreach my $min2 (sort { $a cmp $b } keys %{$final{$min1}}) 214 foreach my $min2 (sort { $a cmp $b } keys %{$final{$min1}})
206 { 215 {
207 printf "%-35s = ", $min1." + ".$min2; 216 printf "%-35s = ", ul($min1)." + ".ul($min2);
208 my $n = 0; 217 my $n = 0;
209 foreach my $res (sort { 218 foreach my $res (sort {
210 $final{$min1}{$min2}{$a} <=> $final{$min1}{$min2}{$b} 219 $final{$min1}{$min2}{$a} <=> $final{$min1}{$min2}{$b}
211 || 220 ||
212 $a cmp $b 221 $a cmp $b
213 } keys %{$final{$min1}{$min2}}) 222 } keys %{$final{$min1}{$min2}})
214 { 223 {
215 print $res."[".$final{$min1}{$min2}{$res}."] "; 224 print ul($res)."[".$final{$min1}{$min2}{$res}."] ";
216 $n++; 225 $n++;
217 } 226 }
218 if ($n > 1) { print " (unstable)"; } 227 if ($n > 1) { print " (unstable)"; }
219 print "\n"; 228 print "\n";
220 $total++; 229 $total++;