__PACKAGE__->define_attributes(qw/ foo bar /); #### sub import { my $caller = (caller)[0]; no strict 'refs'; *{"${caller}::define_attributes"} = \&define_attributes; *{"${caller}::import"} = \&import; } #### { no strict 'refs'; my $i = 0; while(my $caller = (caller($i))[0]) { unless ($caller eq 'main' or $caller eq 'base') { *{"${caller}::define_attributes"} = \&define_attributes; } $i++; } }