How about Export ALL subs

作者:   發佈於:  

I know this code doesn't looks like it's good for production, but it's useful sometimes to write a package that, when used, exports ALL of it's subs to its caller package:


sub import {
    my ($class) = shift;
    my $caller = caller;
    require Devel::Symdump;
    my $ds = Devel::Symdump->new($class);
    no strict;
    for my $f ($ds->functions) {
        my $name = $f;
        $name =~ s/^.*:://;
        *{"$caller\::$name"} = $f;
    }
}