Don't ask to ask, just ask | |
PerlMonks |
Re: Import pragmas like strict and warnings into callers lexical scopeby ikegami (Patriarch) |
on Feb 11, 2011 at 19:44 UTC ( [id://887668]=note: print w/replies, xml ) | Need Help?? |
All strict->import (normally called via use strict) does is modify global var $^H. The compiler uses $^H to determine if it should throw strict errors, among other things. The compiler localises $^H to the block being compiled. This is what produces the lexical scoping of the pragma.
In your example, the block being compiled when strict->import is called is your script's file block, so the strictures stay in effect until the end of the file. Similarly scoped hash %^H is available to modules that want to be lexical pragmas without having to fight Perl for the limited bits in $^H. Update: Added code example. Added mention of %^H.
In Section
Seekers of Perl Wisdom
|
|