Perl Scalar Variables

   



Perl while Loops

The 'while' loop in Perl is a very useful construct that is similar to its counterparts in C and many other programming languages. A 'while' loop exits when a specified condition is no longer true, and the location of this condition can either be in the 'while' statement itself or, by means of 'if/then' logic, inside the loop. Listing C.2 contains an example of a 'while' loop for printing the integers from 0 to 9 inclusive.

Listing C.2 whileLoop1.pl

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

Remarks

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

perl -w whileLoop1.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