in reply to a few questions about __PACKAGE__
I think you want $INC{__PACKAGE__.".pm"};
Also note that the lexical variable my $pathname would go out of scope at the end of the BEGIN block.