Fundamentals of SVG Programming: Concepts to Source Code (Graphics Series)

   


Perl for Loops

The 'for' loop is another useful construct and (just like 'while' loops) it is also similar to its counterpart in C. As you can probably discern from the code fragment, Listing C.3 also prints the integers from 0 to 9 inclusive using a 'for' loop.

Listing C.3 forLoop1.pl

my($count) = 0; for($count=0; $count<10; $count++) { print "count -> $count\n"; }

Remarks

You can launch the Perl script forLoop1.pl in Listing C.3 from the command line as follows,

perl -w forLoop1.pl

and the output is as follows:

count -> 0 count -> 1 count -> 2 count -> 3 count -> 4 count -> 5 count -> 6 count -> 7 count -> 8 count -> 9


   

Категории