http://qs321.pair.com?node_id=948478


in reply to use of "use X"

Thanks for the suggestions folks. No luck finding a solution; am thinking it may not be possible. Although this works:

use if (1 == 1), warnings => qw(all);

am thinking that an eval on $debug *requires* the compiler, therefore compiler directives like "strict, warnings, diagnostics, etc." cannot be loaded in this manner (however, I'm often wrong). For more, see:

http://www.perlmonks.org/?node_id=323606

Replies are listed 'Best First'.
Re^2: use of "use X"
by quester (Vicar) on Jan 18, 2012 at 06:50 UTC

    I think what you were looking for is

    $ perl -E 'BEGIN {our $debug = 1;} use if $debug // 0, warnings; say u +ndef' Use of uninitialized value in say at -e line 1.

    although I would be inclined to go with an environment variable instead, to avoid having to edit the source code:

    $ debug=1 perl -E 'use if $ENV{debug} // 0, warnings; say undef' Use of uninitialized value in say at -e line 1.