my $count = 0; while( $count < 30 ) { print "count $count\n" if ++$count % 3 == 0; } #### my $outfile = "$rootpath$categoryDir$frontPage"; open(TXTFILE, ">", $outfile ) or die "Can't open output file '$outfile': $!\n";