$ perl -Mstrict -lne 'our $c += () = /foo/g; END { print $c }' abc foo foo foo 3 $ perl -Mstrict -lne 'my $c += () = /foo/g; END { print $c }' abc foo foo foo 1