in reply to Access package variables of subclass from base class

for your requirement, this may help you
sub id { my $self = shift; my $class = ref $self; no strict 'refs'; return ${'main::'."$class".'::ID'}; }

Vivek
-- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.

Replies are listed 'Best First'.
Re^2: Access package variables of subclass from base class
by slower (Acolyte) on Mar 04, 2009 at 16:56 UTC
    Interesting, I hadn't stumbled on this one because I had strict enabled. This also works fine, although I don't like disabling strict refs any more than I like using stringy eval:
    no strict 'refs'; return ${ $class . '::ID' };