Help for this page
$ perl -lne '$c += () = /foo/g; END { print $c }'
my $c; while (<>) { $c += () = /foo/g; } print $c, "\n";