Re: Question abount counting the total number of lines and put to an variable?



Here blow is the code I did..

open (MYFILE, '123.txt');
while (<MYFILE>) {
if ($_ =~ /^User:/){
$count = $_+1;
print "$count\n";
}
}
close (MYFILE);

But it shows the result below,
1
1
1

How can I add those together become 3 ?

.