sub LHCC { DECISION: print " Hi. This is the Lee-Hardy Conclusion Calculator.\n Given a series of statements using the syntax\n 'p -> q', I will deduce the correct conclusion\n to be made using basic logic and the chain rule.\n Type 'ready' when you are ready to input your statements.\n Type 'quit' to exit the LHCC.\n\n"; my \$decision = ; chomp \$decision; if(\$decision =~ /quit/i) {if(! &Unit3()) {return 0;}} elsif(\$decision =~ /ready/i) {} else {print "\nCould not interpret, try again.\n"; goto DECISION;} print "\nHow many statements will be used?\n\n"; my \$NumberOfStatements = ; chomp \$NumberOfStatements; if(\$NumberOfStatements !~ /^-?\d+\.?\d*\$/) {print "\nCould not interpret, try again.\n"; goto DECISION;} print "\nOnly a hypen will be accepted for 'not'.\n BTW, with many statements with syntax p -> q, you can't\n have duplicate q's. Sorry. Hey, I only had a week to make\n this thing.\n\n"; print "Given the statements "; my \$StatementNumber = 0; my \$P = 0; my \$Q = 0; my %Statements = (); for \$StatementNumber (1..\$NumberOfStatements) { if (\$StatementNumber != \$NumberOfStatements) {print "P\$StatementNumber -> Q\$StatementNumber, ";} elsif (\$StatementNumber == \$NumberOfStatements) {print "and P\$StatementNumber -> Q\$StatementNumber,\n\n";} else {die "Whut? Something weird just happened, you aren't supposed to be able to see this. Run again and if the error persists, email me at yflee7\@students.d125.org.\n";} } for \$StatementNumber (1..(\$NumberOfStatements*2)) { if(\$StatementNumber % 2 == 0) { my \$TrueStatementNumber = \$StatementNumber/2; print "Q\$TrueStatementNumber = "; \$Q = ; chomp \$Q; if (! \$Q) {print "\nCould not interpret, try again\n"; goto DECISION;} print "\n"; \$Statements{"Q\$TrueStatementNumber"} = \$Q; } elsif(\$StatementNumber % 2 != 0) { my \$TrueStatementNumber = int(\$StatementNumber/2) + 1; print "P\$TrueStatementNumber = "; \$P = ; chomp \$P; if (! \$P) {print "\nCould not interpret, try again\n"; goto DECISION;} print "\n"; \$Statements{"P\$TrueStatementNumber"} = \$P; } else {die "Whut? Something weird just happened, you aren't supposed to be able to see this. Run again and if the error persists, email me at yflee7\@students.d125.org.\n";} } my %Contrapositives = (); for \$StatementNumber (1..\$NumberOfStatements) { \$Contrapositives{"P\$StatementNumber"} = \$Statements{"Q\$StatementNumber"}; \$Contrapositives{"Q\$StatementNumber"} = \$Statements{"P\$StatementNumber"}; } my @ContrapositivesKeys = keys %Contrapositives; for my \$Element (@ContrapositivesKeys) { my \$ToTildeOrNotToTilde = substr \$Contrapositives{\$Element}, 0, 1; my \$RestOfStatement = substr \$Contrapositives{\$Element}, 1; if(\$ToTildeOrNotToTilde eq '-') { \$Contrapositives{\$Element} = \$RestOfStatement; } elsif(\$ToTildeOrNotToTilde ne '-') { \$Contrapositives{\$Element} = "-" . \$Contrapositives{\$Element}; } else {die "Whut? Something weird just happened, you aren't supposed to be able to see this. Run again and if the error persists, email me at yflee7\@students.d125.org.\n";} } @ContrapositivesKeys = keys %Contrapositives; my @StatementsKeys = keys %Statements; for my \$Element (1..\$NumberOfStatements) { \$Statements{\$Statements{"P\$Element"}} = \$Statements{"Q\$Element"}; delete \$Statements{"Q\$Element"}; delete \$Statements{"P\$Element"}; } for my \$Element (1..\$NumberOfStatements) { \$Contrapositives{\$Contrapositives{"P\$Element"}} = \$Contrapositives{"Q\$Element"}; delete \$Contrapositives{"Q\$Element"}; delete \$Contrapositives{"P\$Element"}; } my @Conclusion = (); my @OtherConclusion = (); my \$KeyValueToCheck = 0; my \$key = 0; foreach \$KeyValueToCheck (keys %Statements) { if(!\$KeyValueToCheck) {die "Whut? Something weird just happened.";} my @PossibleConclusion = (\$KeyValueToCheck, \$Statements{\$KeyValueToCheck}); CHECKPOINT: foreach \$key (keys %Statements) { if(!\$key) {die "Whut? Something weird just happened.";} if(\$key eq \$Statements{\$KeyValueToCheck}) { push @PossibleConclusion, \$Statements{\$key}; \$KeyValueToCheck = \$key; } elsif(\$key ne \$Statements{\$KeyValueToCheck}) {} else {die "Whut? Something weird just happened, you aren't supposed to be able to see this. Run again and if the error persists, email me at yflee7\@students.d125.org.\n";} } foreach \$key (keys %Contrapositives) { if(\$key eq \$Statements{\$KeyValueToCheck}) { push @PossibleConclusion, \$Statements{\$key}; \$KeyValueToCheck = \$key; goto CHECKPOINT; } elsif(\$key ne \$Statements{\$KeyValueToCheck}) {} else {die "Whut? Something weird just happened, you aren't supposed to be able to see this. Run again and if the error persists, email me at yflee7\@students.d125.org.\n";} } if (scalar @PossibleConclusion > scalar @Conclusion) {@Conclusion = @PossibleConclusion;} elsif (scalar @PossibleConclusion == scalar @Conclusion) {@OtherConclusion = @PossibleConclusion;} elsif (scalar @PossibleConclusion < scalar @Conclusion) {} else {die "Whut? Something weird just happened, you aren't supposed to be able to see this. Run again and if the error persists, email me at yflee7\@students.d125.org.\n";} } foreach \$KeyValueToCheck (keys %Contrapositives) { if(!\$KeyValueToCheck) {die "Whut? Something weird just happened.";} my @PossibleConclusion = (\$KeyValueToCheck, \$Statements{\$KeyValueToCheck}); CHECKPOINT2: foreach \$key (keys %Statements) { if(\$key eq \$Contrapositives{\$KeyValueToCheck}) { if(!\$key) {die "Whut? Something weird just happened.";} push @PossibleConclusion, \$Statements{\$key}; \$KeyValueToCheck = \$key; } elsif(\$key ne \$Contrapositives{\$KeyValueToCheck}) {} else {die "Whut? Something weird just happened, you aren't supposed to be able to see this. Run again and if the error persists, email me at yflee7\@students.d125.org.\n";} } foreach \$key (keys %Contrapositives) { if(\$key eq \$Contrapositives{\$KeyValueToCheck}) { if(!\$key) {die "Whut? Something weird just happened.";} push @PossibleConclusion, \$Statements{\$key}; \$KeyValueToCheck = \$key; goto CHECKPOINT2; } elsif(\$key ne \$Contrapositives{\$KeyValueToCheck}) {} else {die "Whut? Something weird just happened, you aren't supposed to be able to see this. Run again and if the error persists, email me at yflee7\@students.d125.org.\n";} } if (scalar @PossibleConclusion > scalar @Conclusion) {@Conclusion = @PossibleConclusion;} elsif (scalar @PossibleConclusion == scalar @Conclusion) {@OtherConclusion = @PossibleConclusion;} elsif (scalar @PossibleConclusion < scalar @Conclusion) {} else {die "Whut? Something weird just happened, you aren't supposed to be able to see this. Run again and if the error persists, email me at yflee7\@students.d125.org.\n";} } foreach my \$ScalarNumber (0..((scalar @Conclusion)-1)) { if (\$ScalarNumber != scalar @Conclusion) {print "\$Conclusion[\$ScalarNumber] => ";} elsif (\$ScalarNumber == scalar @Conclusion) {print "\$Conclusion[\$ScalarNumber]";} else {die "Whut? Something weird just happened, you aren't supposed to be able to see this. Run again and if the error persists, email me at yflee7\@students.d125.org.\n";} } print "\n\nor \n\n"; foreach my \$ScalarNumber (0..((scalar @OtherConclusion)-1)) { if (\$ScalarNumber != (scalar @OtherConclusion)-1) {print "\$OtherConclusion[\$ScalarNumber] => ";} elsif (\$ScalarNumber == (scalar @OtherConclusion)-1) {print "\$OtherConclusion[\$ScalarNumber]";} else {die "Whut? Something weird just happened, you aren't supposed to be able to see this. Run again and if the error persists, email me at yflee7\@students.d125.org.\n";} } print "\n\nIn other words, " . \$Conclusion[0] . " => " . \$Conclusion[(scalar @Conclusion)-1] . " or " . \$OtherConclusion[0] . " => " . \$OtherConclusion[(scalar @Conclusion)-1] . "\n"; goto DECISION; } ##```## Use of uninitialized value in print at Unit3.pm line 142, line 12. Use of uninitialized value in string eq at Unit3.pm line 144, line 12. Use of uninitialized value in string ne at Unit3.pm line 149, line 12. Use of uninitialized value in print at Unit3.pm line 142, line 12. Use of uninitialized value in string eq at Unit3.pm line 144, line 12. Use of uninitialized value in string ne at Unit3.pm line 149, line 12. ##``````## Use of uninitialized value \$Conclusion[2] in concatenation (.) or string at Unit3.pm line 203, line 12. c => -b => => or Use of uninitialized value \$OtherConclusion[1] in concatenation (.) or string at Unit3.pm line 210, line 12. Use of uninitialized value \$Conclusion[2] in concatenation (.) or string at Unit3.pm line 214, line 12. f => => -b In other words, c => or f => -b ```