189

Packages & Modules
The Require Function

  • A module can be loaded by calling the require function (See also use )

      require Foo;

      Foo::bar( "a" );
      Foo::blat( "b" );


    Exercise
    1. Take a look at the "Module1.pm" script (click the "Module1.pm" icon).
    2. Run the require example script.
    3. Take a look at the "require" script (click the "require" icon).

    Module1.pm

    require

  • Notice above that the subroutine names must be fully qualified (because they are isolated in their own package)

  • It would be nice to enable the functions bar and blat to be imported into our own namespace so we wouldn't have to use the Foo:: qualifier...