#!/usr/bin/perl # important to initialize variable before loop! $i=0; while ($i<3) { print "i = $i\n"; $i++; # need this line to avoid infinite loop! } # prints the following: # i = 0 # i = 1 # i = 2