> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> To:
> Sent: Monday, March 29, 2004 6:20 AM
> Subject: Incrementing count
>
>
> > 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.
> >
>
> while (<FILE>) {
> $counter=$counter +20;
> }
The result I think the OP wants to achieve is:
$counter = $line = 0;
while (<FILE>)
{
$counter++ unless ($line++ % 20);
}
This one increments $counter every time $line is an multiple of 20.
Even better :
$counter = 0;
while (<FILE>)
{
$counter++ unless ($. % 20);
}
[See perldoc perlvar]
Adrian Ichim
**********************************************************************
PLEASE NOTE: The above email address has recently changed from a previous naming
standard -- if this does not match your records, please update them to use this new
name in future email addressed to this individual.
This message and any attachments are intended for the
individual or entity named above. If you are not the intended
recipient, please do not forward, copy, print, use or disclose this
communication to others; also please notify the sender by
replying to this message, and then delete it from your system.
The Timken Company
**********************************************************************
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>