in reply to Re^2: Which "use" statements in a module do "bubble up" to the callers?
in thread Which "use" statements in a module do "bubble up" to the callers? [SOLVED]

I believe that constants are implemented as functions and have package scope the same as other functions.
C:\Users\Bill\forums\monks>type scope.pl use strict; use warnings; use constant PI => 3.14; my $pi = PI; package B{ my $pi = PI; } C:\Users\Bill\forums\monks>perl scope.pl Bareword "PI" not allowed while "strict subs" in use at scope.pl line +6. Execution of scope.pl aborted due to compilation errors.
Bill
  • Comment on Re^3: Which "use" statements in a module do "bubble up" to the callers?
  • Download Code

Replies are listed 'Best First'.
Re^4: Which "use" statements in a module do "bubble up" to the callers?
by Anonymous Monk on Aug 31, 2017 at 16:29 UTC
    True. Also, the value of a constant is copied into the lexical pad of any code that uses it, just like a literal. And 22/7 is a slightly better approximation of π than 3.14, but 4*atan2(1,1) is much better.
      ... 22/7 is ... slightly better ... but 4*atan2(1,1) is much better.

      And my favorite, 355/113, "slide-rule pi", is right in between the two!


      Give a man a fish:  <%-{-{-{-<

        Even better: Use M_PI from POSIX instead of PI. Oops, that does not illustrate the scope problem.
        Bill