samedi 5 novembre 2016

Perl else error

Hello I am new to programming in perl I am trying to make a number adder (math) but it gives me 1 error here's my code:

sub main {
    print("First: ");
    $num1 = <STDIN>;
    print("Second: ");
    $num2 = <STDIN>;

    $answer = $num1 + $num2;
    print("$answer")
} else {
    print("You have entered invalid arguments.")
}
main;

now obviously its not done but I get an error on ONLY else here is the error:

C:\Users\aries\Desktop>"Second perl.pl"
syntax error at C:\Users\aries\Desktop\Second perl.pl line 9, near "} else"
Execution of C:\Users\aries\Desktop\Second perl.pl aborted due to compilation errors.

please help (also I tried googling stuff still error)

Aucun commentaire:

Enregistrer un commentaire