use warnings; use strict; package My::Mod; use File::Spec; use Carp; my $module = File::Spec->catfile(split('::', __PACKAGE__)); my $modPath; for (@INC) { my $t = File::Spec->catfile($_, $module); if ( -e $t ) { $modPath = $t; last; } } my $configPath = $modPath; if ($modPath) { $configPath =~ s/\.pm$/.yml/; } else { croak("Can't find config file."); }