in reply to Controlling "use" statements
BEGIN { # These will only be used in the # debugging version. if ($DEBUG) { use strict; use warnings; use Data::Dumper; use CGI::Carp; } # These are needed by the program # regardless. use CGI::Minimal; use HTML::Template; # ... others, etc. }
Like BEGIN blocks, use statements execute as soon as they are compiled. Your use CGI::Carp; executes as soon as it is compiled, with no regard to whether that code is reached at run-time. That means the if ($DEBUG) has no bearing on whether use statements inside the if are executed or not.
Secondly, strict and warnings are pragmas. They only affect the lexical block in which they are located (and nested blocks). use strict; would only work for the body of the if.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Controlling "use" statements
by nodice (Initiate) on Jun 13, 2007 at 18:48 UTC | |
by shmem (Chancellor) on Jun 13, 2007 at 19:37 UTC | |
by ikegami (Patriarch) on Jun 13, 2007 at 19:47 UTC |