in reply to Re: 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]

constant is file-scoped.
Sorry, that's wrong, it's package-scoped. Usual practice is to define one package per file, which is the source of my mistake.
  • Comment on Re^2: Which "use" statements in a module do "bubble up" to the callers?

Replies are listed 'Best First'.
Re^3: Which "use" statements in a module do "bubble up" to the callers?
by BillKSmith (Monsignor) on Aug 31, 2017 at 15:39 UTC
    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
      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:  <%-{-{-{-<