Let's say there's a simple Perl script testme.pl like this:
use strict;
use warnings;
sub testme {
return 1;
}
1;
And a test file testme.t like this:
use strict;
use warnings;
use Test::More;
require_ok('testing.pl');
ok(testme());
done_testing();
Running perl testme.t
seems to work as expected, but both http://www.perlmonks.org/bare/?node_id=537361 and https://stackoverflow.com/a/9134624/272387 suggest to add a package line, so I modify the original script to be:
use strict;
use warnings;
package My::Testing;
sub testme {
return 1;
}
1;
Now the test fails with:
Undefined subroutine &main::testme called at testing.t
Why so?