How are Perl's lexically-scoped pragmas implemented?

Viewed 353

Pragmas, like autodie, according to the docs, are lexically scoped.

{
use autodie;
  ..
  ..
}
# Can die here

Does this apply to all modules loaded with use? As far as I know, use is almost the same as:

BEGIN {
  require autodie;
  autodie->import(LIST);
}

BEGIN happens at compile time, and require is not lexically scoped. So how is autodie aware of its scope?

3 Answers
Related