Re: Question abount counting the total number of lines and put to an variable?
- From: rootbeer@xxxxxxxxxx (Tom Phoenix)
- Date: Thu, 29 Nov 2007 19:21:41 -0800
On 11/29/07, Marco <marco@xxxxxxxxxxxx> wrote:
The code will show 2 line liek below, how can I get the a number "2"
and save to the variable? thanks.
User: ABC
User: DEF
It sounds as if you want to count each print operation. You can do
that if you set a variable to zero before you begin printing:
my $lines = 0;
Then, each time you print a line, you add one to $lines.
print "whatever\n";
$lines++; # add one to $lines
After you've finished printing, $lines will hold the value you need. Is that it?
Cheers!
--Tom Phoenix
Stonehenge Perl Training
.
- References:
- Prev by Date: Re: Question abount counting the total number of lines and put to an variable?
- Next by Date: Re: Question abount counting the total number of lines and put to an variable?
- Previous by thread: Re: Question abount counting the total number of lines and put to an variable?
- Next by thread: Re: Question abount counting the total number of lines and put to an variable?
- Index(es):