While using scalar values in perl, I am not able to accomplish the desired results. Need your help in figuring where I am going wrong..
Say I want to loop 9 times and print 0.1 to 0.9
I declared variable $i and using it in for loop as well as inside the loop.
for($i = 1; $i < 10; $i++)
{
$b = $ie-01; # (This where I go wrong, I am not sure If I am following correct
# syntax here, Because I see -1 getting printed instead of $i value
# which is incremented on each loop)
print "The value now is: $b\n";
}
I do know of different ways to get the desired result but I wanna know how to use exponent to get the desired output. . . . .
Why $i is treated as 0 when used in conjunction with e?
I think you only forgot to include the multiplication operator
*:The string
$ie-01will be interpreted as$ie - 01which is an unititialized variable (i.e. zero) minus one which will give you-1. (You can use thee-notation only with constant numbers but not with variables.)