Perl练习之——循环语句

#if elsif else 条件语句

$i = ;
chomp $i ;
if($i < 10){
    print "Number is less than 10" ;
} elsif($i > 20){
    print "Number is more than 20" ;
} else{
    print "Number is between 10 and 20." ;
}

#循环语句
$counter = 0 ;
while($counter < 5){
    print "counter is $counter,  " ;
    print "$counter 小于5,进行循环\n" ;
    $counter++  
}


#for 循环
$i = 5 ;
for(;$i >2;){
    print "i is $i\n" ;
    $i--
}
$i = 5 ;
for(;$i>2;$i--){
    print "is now is $i \n" ;
}



你可能感兴趣的:(测试,perl,less)