factorio-recipe-analyzer/fra.pl

88 lines
1.8 KiB
Perl
Raw Normal View History

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