in reply to Re: Common Perl Idioms
in thread Common Perl Idioms

Did you know that the 'if(0)' won't inhibit the loading of Data::Dumper, even if the 'use' is inside the 'if'? That's because 'use' operates at compile time before the optimizer has a chance to remove the dead code.

-sam

Replies are listed 'Best First'.
Re^3: Common Perl Idioms
by greenFox (Vicar) on Jul 26, 2004 at 02:55 UTC

    I learnt this the hard way. I used to write:

    if ( $DEBUG ){ use CGI::Carp qw(fatalsToBrowser); }

    thinking that when I put the code into production all my debugging would dissapear with a simple $DEBUG=0; but Carp is always loaded no matter the value of $DEBUG. It took a long while for me to notice the error becuase when run in prod the conditions which would trigger a die didn't normally occur. My bad.

    --
    Do not seek to follow in the footsteps of the wise. Seek what they sought. -Basho