in reply to syntax question: conditional 'use' statement?

Of course you can always use require for Data::Dumper module, i.e. as in
BEGIN { use constant DEBUG => 1; if (DEBUG) { require Data::Dumper; } }
However, this would not work for warnings since it works during compilation time. Moreover, as a rule of thumb I would recommend to always include both use strict and use warnings in every perl program. Believe it or not, it will catch a lot of errors and typos and reduce the debugging time greatly. Even for the advance programming you can always localize the effect by temporarily switching off both warnings and strict with no warnings and no strict directives.

Replies are listed 'Best First'.
Re^2: syntax question: conditional 'use' statement?
by ikegami (Patriarch) on Sep 19, 2006 at 15:59 UTC
    You forgot to import.
    BEGIN { use constant DEBUG => 1; if (DEBUG) { require Data::Dumper; Data::Dumper->import() if Data::Dumper->can('import'); } }