in reply to Variable scoping problem

The second time you try to require "a.pl"; has no effect because a.pl is already loaded. To ensure the other scripts are always executed by c.pl, use do instead of require.

do "a.pl"; print "$database\n"; do "b.pl"; print "$database\n"; do "a.pl"; print "$database\n";

Replies are listed 'Best First'.
Re^2: Variable scoping problem
by haukex (Archbishop) on Nov 25, 2019 at 22:50 UTC
    use do instead of require

    Yes, but do requires additional error checking to make sure it actually worked (the docs show one example, that could be simplified a bit).

      Thank you. I replaced "require" with "do" and the program now works.