in reply to Common subs and Global Variables

The recommended clean way to do this is to export variables and functions, see import and Exporter

What you're doing works in Linux and won't go away.

But once someone wants to introduce new namespaces via package or have better control which vars and subs are included, you'll likely run into problems.

Edit

PS: FWIW what you're doing is similar to "sourcing" in shell languages, and could already be done with do FILE instead of use ...

...and frankly I'm surprised you don't need a use lib "."; to allow modules in the local . dir

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: Common subs and Global Variables
by hippo (Archbishop) on Mar 19, 2024 at 15:10 UTC
    I'm surprised you don't need a use lib ".";

    The Anonymous OP said "This is in Windows 10 (ugh) using Strawberry perl v5.20.2." and I'm pretty sure . was only removed in a later version (5.26 maybe?).


    🦛

      5.26 in entirely correct: https://metacpan.org/release/XSAWYERX/perl-5.26.0/changes

      For security reasons, the current directory (".") is no longer included by default at the end of the module search path (@INC). This may have widespread implications for the building, testing and installing of modules, and for the execution of scripts. See the section "Removal of the current directory (".") from @INC" for the full details.

      PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP