in reply to Module Readonly

Could you elaborate on the scoping problems use constant has? I didn't find a hint via quick googling or in its pod.

Just curious...

regards,
tomte


An intellectual is someone whose mind watches itself.
-- Albert Camus

Replies are listed 'Best First'.
Re: Re: Module Readonly
by hardburn (Abbot) on Apr 23, 2004 at 13:16 UTC

    constant creates a subroutine, which in Perl5 is global to the package. You can fake lexically-scoped subroutines by putting them in a variable (my $sub = sub { . . . };), but that doesn't really help with constants since you can still change the variable that holds the sub ref.

    ----
    : () { :|:& };:

    Note: All code is untested, unless otherwise stated

Re: Re: Module Readonly
by Anonymous Monk on Apr 23, 2004 at 14:53 UTC
      ? The only mention I see there of scoping is a mention that "use constant" constants are global, not lexically scoped. How is that a problem?