factorio-recipe-analyzer/fra.pl
2023-08-24 17:34:51 +02:00

75 lines
1.4 KiB
Perl

our @patterns = (
# 0 metal
"m/[\-?,?s*]
(bronze|iron|steel|copper|
zinc|lithium|tungsten|titanium|tin|
nickel|silver|platinum|manganese|
lead|gold|aluminium|aluminum)
[\-?,?\s*]/",
# 1 wood
"m/[\-?,?s*]
(seedlings|wood|wooden)
[\-?,?\s*]/",
# 2 plastic
"m/[\-?,?s*]
(plastic)
[\-?,?\s*]/",
# 3 electronics
"m/[\-?,?s*]
(electronic)
[\-?,?\s*]/",
# 4 glass
"m/[\-?,?s*]
(glass)
[\-?,?\s*]/",
# 5 stone
"m/[\-?,?s*]
(limestone|stone|slag|concrete|sand)
[\-?,?\s*]/");
open(my $in, "<", "./mod-recipes/intermediate.csv") or die "Can't open intermediates.csv";
open(my $out, ">", "./mod-recipes/output.csv") or die "Can't open output.csv";
while (<$in>) {
my @line = split(",", $_);
if ($line[1] =~ "$patterns[0]") {
print $out "metal @line";
print "$patterns[0]";
print "metal @line";
}
elsif ($line[1] =~ "$patterns[1]") {
print $out "wood @line";
}
elsif ($line[1] =~ "$patterns[2]") {
print $out "plastic @line";
}
elsif ($line[1] =~ "$patterns[3]") {
print $out "electronics @line";
}
elsif ($line[1] =~ "$patterns[4]") {
print $out "glass @line";
}
elsif ($line[1] =~ "$patterns[5]") {
print $out "stone @line";
}
else {
print $out "@line";
print "@line";
}
}
close $in or die "$in: $!";
close $out or die "$out: $!";