I'm not convinced this is worth doing (using more standard test methods is pretty simple, and lets the user delete the test code once they've installed the module), but
caller provides the information you need to determine whether you're inside of a
use or
require:
#!/usr/bin/perl
if (!(caller(0))[7])
{
# Not inside of a use
print "Running tests...\n";
}
sub some_sub
{
print "Running some_sub\n";
}
1;