comparison materials/parsealloys.pl @ 317:a4dff42fc40e misc

Make alloy parser less verbose.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 30 Dec 2015 12:21:00 +0200
parents 72bf6267e34f
children 32c434c34238
comparison
equal deleted inserted replaced
316:fedf17494a35 317:a4dff42fc40e
42 ### Parse data from input, ignoring fumbled alloys 42 ### Parse data from input, ignoring fumbled alloys
43 ### 43 ###
44 my %data = (); 44 my %data = ();
45 my $fumble = 0; 45 my $fumble = 0;
46 my $nline = 0; 46 my $nline = 0;
47 my $ignored = 0;
48
47 49
48 sub addCombo($$$) 50 sub addCombo($$$)
49 { 51 {
50 if (!$fumble) 52 if (!$fumble)
51 { 53 {
52 push(@{$data{$_[1]}{$_[2]}}, $_[0]); 54 push(@{$data{$_[1]}{$_[2]}}, $_[0]);
53 } 55 }
54 else 56 else
55 { 57 {
56 print STDERR "Ignoring fumbled combo $_[1] + $_[2] = $_[0]\n"; 58 $ignored++;
59 #print STDERR "Ignoring fumbled combo $_[1] + $_[2] = $_[0]\n";
57 } 60 }
58 $fumble = 0; 61 $fumble = 0;
59 } 62 }
60 63
61 64
72 elsif (/^(You slip up and fumble your attempt)/) 75 elsif (/^(You slip up and fumble your attempt)/)
73 { 76 {
74 $fumble = 1; 77 $fumble = 1;
75 } 78 }
76 } 79 }
80
81 print STDERR "Ignored ".$ignored." fumbled alloys.\n";
77 82
78 83
79 ### 84 ###
80 ### Re-format the data into single "ordered" hash, using as 85 ### Re-format the data into single "ordered" hash, using as
81 ### close to alphabetical order as possible. 86 ### close to alphabetical order as possible.