87 lines
1.8 KiB
Perl
87 lines
1.8 KiB
Perl
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";
|
|
|
|
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*]/");
|
|
|
|
|
|
while (<$in>) {
|
|
@line = split(",", $_);
|
|
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";
|
|
}
|
|
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";
|
|
}
|
|
}
|
|
}
|
|
close $in or die "$in: $!";
|
|
close $out or die "$out: $!";
|