You have use strict; so you must declare variables or the error you see will be thrown. If you've copied/paste this without understanding I suggest you read and understand strict. An alternative would be to declare $i within the for loop.
"How to merge these three lines"
One way to write this:
use strict; use warnings; my $number=8; for( my $i=0; $i<20; $i++ ){ print "present value of the number is: $number\n"; $number++; }
If you are new to perl the following links will likely be of interest:
In reply to Re: usage of "my" keyword
by marto
in thread usage of "my" keyword
by ravi45722
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |