Update: Perl6 added to end of subject.
Welcome to the monastery, jibberjabber! Since you are just starting down your Perl journey, you might want to consider taking the new Perl 6 path. (See all the buzz of Perl 5's sister language, recently released Perl 6, at http://perl6.org). For comparison with Perl 5, I have translated your code (and contributions by jcb and choroba) into Perl 6:
#!/usr/bin/env perl6 say q:heredoc/END/; Type in the correct answer, Hit enter key to continue, if it is not correct the program will not move on to a new problem, think about your answer, and try again, when it is the correct answer, it will tell you, and give a new problem. END while 1 { my $random = 11.rand.Int; my $random2 = 11.rand.Int; say "$random x $random2"; my $x = $random * $random2; while 1 { my $answer = get; if ($answer eq $x) { say "Great, $answer is correct."; say "Hit enter to continue, Ctrl+C to exit."; get; last; } else { say "Sorry, $x is not correct, please try again."; } } }
Note that in Perl 6, the strict and warnings pragmas are the default so do not have to be explicitly used.
In reply to Re: Basic Times Table excercise [Perl6]
by u65
in thread Basic Times Table excercise
by jibberjabber
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |