Perl & Python: “while” Loop Example

Advertise Here

, 2005-01-12, 2011-07-22

Python

#-*- coding: utf-8 -*-
# python

x = 1
while x < 9:
    print x
    x += 1

http://docs.python.org/reference/compound_stmts.html#while

Perl

#-*- coding: utf-8 -*-
# perl

$x = 1;
while ($x < 9) {
  print $x, "\n";
  $x++
}

perldoc perlsyn

blog comments powered by Disqus