in reply to How do you get around the lexical scoping of use pragmas?

Note that use strict boils down to

BEGIN { require 'strict.pm'; strict->import(); }

So strict->import() actually applies to the lexical scope one step outside of from where import() was called (or something like that). So, the following actually works:

package AID; require strict; require warnings; sub import { strict->import(); goto &warnings::import; } 1;

Then:

use AID; BEGIN { print 0+""; } print $x;

Gives:

Argument "" isn't numeric in addition (+) at - line 2. Global symbol "$x" requires explicit package name at - line 3. Execution of - aborted due to compilation errors.

And diagnostics.pm isn't lexically scoped (and I'm not sure why people even use it, to be quite frank), so you can just "use diagnostics" inside your common.pm file.

- tye        

Replies are listed 'Best First'.
Re^2: How do you get around the lexical scoping of use pragmas? (import)
by aufflick (Deacon) on Aug 28, 2006 at 08:21 UTC
    Brilliant! Makes perfect sense, but I wouldn't have even followed this thought process.

    I'd recommend anyone implementing this should document it heavily!