Listing 2.3. Using a blessed reference to invoke methods from the Foo module.
use Foo;
my $packageref = {}; # must be a reference
bless $packageref, Foo; # bless $packageref into the foo package directly
$loaded = FooLoad("FooFile");
$newFoo = $packageref->Get($loaded);
$packageref->Print($newFoo);
This syntax just looks and feels cleaner, in my opinion. But there's more than one way to do it, as always, with Perl.
That wraps up the discussion regarding design and intent of modules and extensions. The following sections deal with the type of module that provides its own subroutines and doesn't load a shared library, which I call a regular module. Most of the WWW modules are of this type. Using Regular Modules Now we return to the Customer package from earlier in this chapter, where we were already doing most of the things discussed up to this point. Add a short POD for brevity, and one additional method, called addstat(), to wind up with what's shown in Listing 2.4.