in reply to Filename of current package

amwl - thank you, caller() is the key, and Carp::Heavy has the detail - my problem was that I was doing it in the new() - checking caller in a sub-routine of the same package provides the answer:

package My::Factory; 1; sub new { my $factory = shift; my $name = shift; my $classfile = package_name(); $classfile =~ s/Factory.pm$/$name.pm/; if ( -e $classfile ) { require $classfile; my $classname = "My::$name"; return $classname->new(@_); } else { die "class not found: $classfile"; } } sub package_name { my (@called) = caller(0); return $called[1]; }