while () { if (/foo/) { $count++; print "$count so far.\n"; } }