factorio-recipe-analyzer/fra.pl

76 lines
1.4 KiB
Perl
Raw Normal View History

2023-08-24 17:34:51 +02:00
our @patterns = (
2023-08-23 17:02:15 +02:00
# 0 metal
"m/[\-?,?s*]
2023-08-24 17:34:51 +02:00
(bronze|iron|steel|copper|
zinc|lithium|tungsten|titanium|tin|
nickel|silver|platinum|manganese|
lead|gold|aluminium|aluminum)
2023-08-23 17:02:15 +02:00
[\-?,?\s*]/",
# 1 wood
"m/[\-?,?s*]
2023-08-24 17:34:51 +02:00
(seedlings|wood|wooden)
2023-08-23 17:02:15 +02:00
[\-?,?\s*]/",
# 2 plastic
"m/[\-?,?s*]
2023-08-24 17:34:51 +02:00
(plastic)
2023-08-23 17:02:15 +02:00
[\-?,?\s*]/",
# 3 electronics
"m/[\-?,?s*]
2023-08-24 17:34:51 +02:00
(electronic)
2023-08-23 17:02:15 +02:00
[\-?,?\s*]/",
# 4 glass
"m/[\-?,?s*]
2023-08-24 17:34:51 +02:00
(glass)
2023-08-23 17:02:15 +02:00
[\-?,?\s*]/",
# 5 stone
"m/[\-?,?s*]
2023-08-24 17:34:51 +02:00
(limestone|stone|slag|concrete|sand)
2023-08-23 17:02:15 +02:00
[\-?,?\s*]/");
2023-08-24 17:34:51 +02:00
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";
2023-08-23 17:02:15 +02:00
2023-08-23 16:01:53 +02:00
while (<$in>) {
2023-08-24 17:34:51 +02:00
my @line = split(",", $_);
2023-08-23 17:02:15 +02:00
if ($line[1] =~ "$patterns[0]") {
print $out "metal @line";
2023-08-24 17:34:51 +02:00
print "$patterns[0]";
print "metal @line";
2023-08-23 17:02:15 +02:00
}
2023-08-24 17:34:51 +02:00
elsif ($line[1] =~ "$patterns[1]") {
2023-08-23 17:02:15 +02:00
print $out "wood @line";
}
2023-08-24 17:34:51 +02:00
elsif ($line[1] =~ "$patterns[2]") {
2023-08-23 17:02:15 +02:00
print $out "plastic @line";
2023-08-23 16:01:53 +02:00
}
2023-08-24 17:34:51 +02:00
elsif ($line[1] =~ "$patterns[3]") {
2023-08-23 17:02:15 +02:00
print $out "electronics @line";
}
2023-08-24 17:34:51 +02:00
elsif ($line[1] =~ "$patterns[4]") {
2023-08-23 17:02:15 +02:00
print $out "glass @line";
}
2023-08-24 17:34:51 +02:00
elsif ($line[1] =~ "$patterns[5]") {
2023-08-23 17:02:15 +02:00
print $out "stone @line";
}
else {
print $out "@line";
2023-08-24 17:34:51 +02:00
print "@line";
2023-08-23 17:02:15 +02:00
}
}
2023-08-23 16:01:53 +02:00
close $in or die "$in: $!";
close $out or die "$out: $!";