#example: your call of find() find ( { no_chdir => 1, wanted => sub { $self->load_api_modules($File::Find::name) }, follow =>1 }, 'api'); #### sub load_api_modules { my $self = shift; my $file = shift; local $_ = $file;#will work with $_ and keep $file return unless s/\.pm$//; require $file; my @sup = split m#/#; # s#/#::#g; unneccessary $self->{ $sup[1].$sup[2] } = $sup[@sup-1]->new(); $self->logObj->log( location => "Initialisation", message => "loaded: $file" ); }