Reverse the output using for loop

Good morning!!

Im trying to ge tthe output in this for loop to be reversed.

[code]
#!/usr/bin/perl
$i = 1;
for($i != 0 ; $i < 11 ; $i++){
print "$i\n";
}

Ive tried changing the i++ to i--, but it makes the outputted numbers different also.

Thanks
bigben

#!/usr/bin/perl
$i = 10;
for($i != 0 ; $i > 0 ; $i--){
print "$i\n";
}

cheers,
Devaraj Takhellambam

You try the following code.
You want the numbers 1 to 10 should be printed in reversed order.Am I correct.The following script will do that.

my $i = 1;
for($i=10; $i > 0; $i--){
print "$i\n";
}

THANKS so much!!! Why was my 11 wrong?

Your $1 value is 1 .So when you decrement it by one you will get strange output because the output will go like 0,-1,-2 ,etc .But if we increment you will get the output in a non reverse order till 10.