my $DEBUG;
BEGIN { $DEBUG = $ARGV[0]; }
use if $DEBUG, 'strict';
# <-- The compiler is here because
# Perl executes use statements
# as soon as it compiles them.
# "strict" will work until the
# end of this block (namely
# until the end of the file).
print($test); # strict error if $DEBUG
####
my $DEBUG;
BEGIN {
$DEBUG = $ARGV[0];
if ($DEBUG) {
require strict;
import strict;
}
}
# <-- The compiler is here because
# Perl executes BEGIN blocks
# as soon as it compiles them.
# "strict" will work until the
# end of this block (namely
# until the end of the file).
print($test); # strict error if $DEBUG
####
my $DEBUG;
BEGIN {
$DEBUG = $ARGV[0];
if ($DEBUG) {
eval <<'__EOI__';
use strict;
# <-- The compiler instance used
# by eval is here because
# Perl executes use statements
# as soon as it compiles them.
# "strict" will work until the
# end of this block (namely
# until the end of the code
# passed to eval).
__EOI__
}
}
print($test); # No strict error