我想在Perl中实现与以下Ruby代码等效的功能:
class Foo
MY_CONST = {
'foo' => 'bar',
'baz' => {
'innerbar' => 'bleh'
},
}
def some_method
a = MY_CONST[ 'foo' ]
end
end
# In some other file which uses Foo...
b = Foo::MY_CONST[ 'baz' ][ 'innerbar' ]
也就是说,我想声明一个常量的嵌套哈希结构,既可以在类内部使用,也可以在外部使用。怎么做?