in reply to 'Required' config file produces error if last entry sets variable to zero?

A file which is required or used must end with a true value. Just make

1;
the last line of the config file.

It doesn't seem well-known, but return will stop execution of a loaded file, making return 0; a way to cancel loading and return 1; a way to say "You don't need the rest of this."

(Added) To keep strict happy, you should add,

use vars qw/$v1 ..... $variable $flag/;
to the top of the file. Tacking on my won't work, since lexical variables only have file scope, at most, and can't be seen from the require-ing program.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: 'Required' config file produces error if last entry sets variable to zero?
by punch_card_don (Curate) on Jun 11, 2006 at 15:27 UTC
    Thanks - that's exactly what I did to make it work, but I thought it was a hack.




    Forget that fear of gravity,
    Get a little savagery in your life.