I'm trying to make a really really really basic rpg. This is how it starts.
Unfortunately, I seem to have gotten my if/elsif statements mixed up. Because whatever option you choose, it always prints 'LOLOL'
I'm not sure why.
[code=perl]
#!/usr/bin/perl
$left = 'left';
$right = 'right';
print "You\'re walking along, and you see a fork in the road. What do you do\?.\n";
print "Turn left\?\n";
print "Turn right\?\n";
$choice = <stdin>;
chomp $choice;
if ($choice == $left) {
print "LOLOL";
}
elsif ($choice == $right) {
print "HAHA";
}
else {
print "PRINT A VALID OPTION MAAAAAN";
}
[/code]
Unfortunately, I seem to have gotten my if/elsif statements mixed up. Because whatever option you choose, it always prints 'LOLOL'
I'm not sure why.
[code=perl]
#!/usr/bin/perl
$left = 'left';
$right = 'right';
print "You\'re walking along, and you see a fork in the road. What do you do\?.\n";
print "Turn left\?\n";
print "Turn right\?\n";
$choice = <stdin>;
chomp $choice;
if ($choice == $left) {
print "LOLOL";
}
elsif ($choice == $right) {
print "HAHA";
}
else {
print "PRINT A VALID OPTION MAAAAAN";
}
[/code]
Comment