Perl programming: can you increment a counter variable by a decimal?

Tutoring programming, you encounter all kinds of instances. The tutor mentions, with Perl, incrementing a counter variable in a for loop by a decimal amount.

Can you increment a counter variable by a decimal amount? In my experience, with Perl, you can:

for($i=0;$i<0.1;$i+=0.01){ print "Now i is ".$i."\n"; }

prints, in my terminal,

0.01
0.02
0.03
[and so on]

Source:

McGrath, Mike. Perl in easy steps. Southam: Computer Step, 2004.

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Leave a Reply