Greetings there foreign forum visitors. I am completely new to programming, in fact i have only started today, but i am a fast learner. I decided to undertake Perl and i wrote a simple program that has 2 main loops , each of which are supposed to take an input value number from the user, and check if it fits the requirements (being between 1 and 100 ), and then it will multiply them and find the module. Pretty straight forward. This is what i wrote:
use strict;
print "this is just a test", "\n";
MAIN_LOOP1:
print "please enter the first number between 1 and 100", "\n";
my $X = <>;
chomp($X);
for $X (1 .. 100)
{
print "now onto the next step", "\n";
else
{
print " the number does not meet the above requirment", "\n";
next MAIN_LOOP1;
}
}
MAIN_LOOP2:
print "please enter the second number between 1 and 100", "\n";
my $Y = <>;
chomp($Y);
for $Y (1 .. 100)
{
print "now onto the calculations", "\n";
else
{
print " the number does not meet the above requirment", "\n";
next MAIN_LOOP2;
}
}
print $X, " * ", $Y, " = ", ($X*$Y), "\n";
print "Finding the module" . "\n";
print $X, " % ", $Y, " = ", ($X%$Y), "\n";
print "Terminate", "\n";
And when i try to execute it in my perl cmd, i get the following errors.
c:\Strawberry\SCRIPTS>perl new.pl
syntax error at new.pl line 11, near "else"
syntax error at new.pl line 16, near "}"
syntax error at new.pl line 24, near "else"
syntax error at new.pl line 29, near "}"
Execution of new.pl aborted due to compilation errors.
Now i have searched over the forums a bit and i seemed to find other users with the same problem but none of the answers i found ultimately changed the outcome, so i thought to post my thread.
NOTE: This is my first ever program so no making fun. Also if anyone has any better syntax or recommendations, they r more than welcome.