package Super::Class; my $idx = 0; sub NEXT_IDX { return $idx++ }; use constant FOO_IDX => NEXT_IDX(); use constant BAR_IDX => FOO_IDX + 1; use constant BAZ_IDX => BAZ_IDX + 2; package Sub::Class; # need to wrap in BEGIN blocks so SUPER:: works in the use at # compile time. BEGIN {our @ISA = qw(Super::Class)}; use constant OTHER_IDX => __PACKAGE__>SUPER::NEXT_IDX(); # oops! NEXT_IDX() is still set to '0' up there, and we just set # OTHER_IDX to 1, clobbering whatever's in the BAR_IDX field!