to something like this:while (<FILE>) { if (/foo/) { $count++; print "$count so far.\n"; } }
update: or something like this:while (<FILE>) { while (/foo/g) { $count++; print "$count so far.\n"; } }
while (<FILE>) { $count++ while /foo/g; } print $count;
-enlil
In reply to Re: Counting text strings
by Enlil
in thread Counting text strings
by vector40
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |