in reply to Re: Way to insert some ad code
in thread Way to insert some ad code
Using the modulo (%) operator is probably a bit more idiomatic way to do this rather than explicitly resetting the counter.
my $count = 0; while( $count < 30 ) { print "count $count\n" if ++$count % 3 == 0; }
Update: And a gripe for the OP: your open statement would be better written:
my $outfile = "$rootpath$categoryDir$frontPage"; open(TXTFILE, ">", $outfile ) or die "Can't open output file '$outfile': $!\n";
You'll be thanking yourself for providing a useful error message n months down the road when something changes and you're one step closer to fixing it rather than trying to chase down a mysterious "write on a closed filehandle" error.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Way to insert some ad code
by eric256 (Parson) on Jan 25, 2007 at 20:28 UTC |