jeudi 29 mars 2018

perl conconditional script not working

i made this small Perl script but when i run it in the terminal ($ Perl perltest.pl) it says syntax error at perltest.pl line 6, near ") {" Execution of perltest.pl aborted due to compilation errors. i am not sure what is wrong with my code, I've fiddled with it for hours. Thanks!

use strict;
use warnings;
print "enter a number\n";   
my $num = readline STDIN;
chomp ($num)
if ($num < 10) {
    print "its less than 10\n";
}
elsif ($num > 10) {
    print "its greater than 10\n";
}
else (
    print "its 10\n";
)

Aucun commentaire:

Enregistrer un commentaire