Perl while Loops

   



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

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

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



   



Fundamentals of SVG Programming. Concepts to Source Code
Fundamentals of SVG Programming: Concepts to Source Code (Graphics Series)
ISBN: 1584502983
EAN: 2147483647
Year: 2003
Pages: 362

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net