in reply to use depending on environment

You'll need a BEGIN block. Note, however, that the logic to set your $online flag will have to be included in that block, or one prior to it, something like this:

BEGIN { # Code to set $online here. # $online = 1 if whatever.... if ($online) { use POSIX 'locale_h'; setlocale( LC_ALL, "pt_BR.iso88591" ); } }

Replies are listed 'Best First'.
Re^2: use depending on environment
by jZed (Prior) on Jun 22, 2005 at 15:49 UTC
    Does that really work? Since use is compile time, this will error out even if the condition isn't met:
    #!/usr/bin/perl -w use strict; BEGIN { if (0) { use Non_existant_module; } }
Re^2: use depending on environment
by Andre_br (Pilgrim) on Jun 22, 2005 at 15:59 UTC
    Thanks for the replies. But are you sure this locale deffinition will be valid for the entire script? The BEGIN block provides that?