Sports > Baseball > SF Giants
What are the elseif statements needed to do the following? I have tried many different ways and I am not sure how to do it. What would the example code look like?
if category = "SF Giants" then include "giants.txt" or else
if category = "NY Yankees" then include "yankees.txt or else
if category = "AZ Diamondbacks" then include "diamondbacks.txt
Does this make sense?
Then obviously I would want to add something at the end where if there was no match, there would be a default .txt file.
I greatly appreciate any help with this. :)
if (category = "SF Giants") {include "giants.txt"}
elsif (category = "NY Yankees") {include "yankees.txt"}
elsif (category = "AZ Diamondbacks") {include "diamondbacks.txt"}
else {include "default.txt"} SWITCH: {
if (category = "SF Giants") {include "giants.txt"; last SWITCH; }
if (category = "NY Yankees") {include "yankees.txt"; last SWITCH; }
if (category = "AZ Diamondbacks") {include "diamondbacks.txt"; last SWITCH; }
include "default.txt";
}
Unfortunately the code is not working. I am messing with it to try different versions to see if it works, but it doesn't. I kept getting errors until I wrote the code this way, and then it at least didn't have errors, but it still didn't work.
{{if category="SF Giants"}} {{include name="giants.txt"}}
{{/if}}
{{if category="NY Yankees"}} {{include name="yankees.txt"}}
{{/if}}
{{if category="AZ Diamondbacks"}} {{include name="diamondbacks.txt"}
{{else}}
{{include name="default.txt"}} {{/if}}
Any ideas on where to go from here? This is fun but at the same time frustrating. I love learning perl, but I am pretty confused sometimes.
I am very appreciative of the help. Thanks!
my $category = 'NY Yankees';
SWITCH: {
if ($category = "SF Giants") {print "giants!"; last SWITCH; }
if ($category = "NY Yankees") {print "yankees!"; last SWITCH; }
if ($category = "AZ Diamondbacks") {print "diamondbacks!"; last SWITCH; }
print "default!";
}
{{if category.label eq "SF Giants"}}
{{include name="giants.txt"}}
{{elsif category.label eq "NY Yankees"}}
{{include name="yankees.txt"}}
{{else}}
{{include name="default.txt"}}
{{/if}}
It ended up being pretty simple when it was all said and done. I thank you for helping me out!