in reply to Using do to read config
do FILE; returns the value of the last statement in FILE, so globalizing things isn't really necessary. That property can be used to restrict visibility of the configuration:
Attempts to make use of $conf outside the BEGIN block will fail.$ cat foo.conf my %conf = ( passwd => 'joe', uname => 'joe', foo => 1, ); \%conf; $ perl -w -Mstrict -e 'BEGIN{my $conf = do "foo.conf";sub whisper {pri +nt $conf->{passwd},$/}} whisper()' joe
After Compline,
Zaxo
|
|---|