module-authors:
Let's say I have a CPAN distribution called Foo:
# Foo.pm
package Foo;
And suppose the distribution includes:
package Foo::Bar;
sub mysub { print "hello, world!\n" }
I would like callers to be able to import mysub() with a traditional
'use' statement and import list:
#!/usr/bin/perl
# myscript.pl
use strict;
use warnings;
use Foo qw( mysub );
mysub();
If mysub() were in Foo, I would know how to accomplish the goal with
Exporter, @Foo::Export_OK, etc.. But because mysub() is in Foo::Bar, I
don't think the traditional approach will work. RTFM Exporter makes me
wonder if I should write Foo::import() and call
Exporter::export_to_level() (?).
Bonus question:
use Foo qw( :all );
What is the best way to accomplish the goal?
TIA,
David
p.s. My motivation for this question is as follows -- I am writing some
exception throwing code that calls Carp::confess() internally and would
like to apply the %Carp::Internal feature so that the error messages the
user sees start at the point where they called my code, not where my
code calls confess(). I don't what to put my whole distribution package
into %Carp::Internal, so I'm thinking I'll put the throwing subroutines
into their own package and put that package name into %Carp::Internal.