On Mon, 29 Mar 2004 12:08:33 -0600 James Edward Gray II <[EMAIL PROTECTED]> wrote:
> On Mar 29, 2004, at 8:20 AM, [EMAIL PROTECTED] wrote: > > > I'm sorry, the previous subject should have been changed. My > > apologies. > > > > > > while (<FILE>) { > > $counter++; > > } > > > > I know this is probably simple, but how would I increment by 20? In > > other > > words, $counter would increment 1 time for every twenty lines of the > > file? Any > > help would be appreciated. > > $counter += 20; This is not what the poster asked. This will increment the counter by 20 for every line of the file. Something like this does what the original poster wants: while (<FILE>) { $counter++ if ! ($. % 20); } This increments the counter by one for every 20 lines of input. $. is the input line counter. % is the modulo operator. See perlvar for the details on $. and perlop for the modulo operator. -- Smoot Carl-Mitchell Systems/Network Architect email: [EMAIL PROTECTED] cell: +1 602 421 9005 home: +1 480 922 7313 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>