为什么常量不会自动继承?

ask*_*ker 2 perl

正如我们constant在Perl中所知道的那样sub,

但他们为什么不继承?

bvr*_*bvr 10

事实上,它们是:

use strict; use warnings;

package Father;
use constant CONST => 1;

package Child;
use base 'Father';
sub new { bless {}, shift }

package main;
my $c = Child->new;
print $c->CONST;        # 1
print CONST();          # undefined subroutine
Run Code Online (Sandbox Code Playgroud)