use Test::More; use vars qw($n_tests); use_ok 'Foo::bar'; BEGIN { $n_tests++ } my $c = 10; for (1..$c) { ok Foo::new->($_); } # BEGIN { $n_tests += $c } # oops, wrong. my $c not visible here BEGIN { $n_tests += 10 } # ... and so on # at last: BEGIN { plan tests => $n_tests }