DekGenius.com
[ Team LiB ] Previous Section Next Section

12.4 A More Typical Object-Oriented Module: Math::BigInt

So as not to get dismayed about how "un-OO" the File::Spec module might be, let's look at yet another core module, Math::BigInt:

use Math::BigInt;
my $value = Math::BigInt->new(2); # start with 2
$value->bpow(1000);               # take 2**1000
print $value->bstr(  ), "\n";       # print it out

Here, nothing is imported. The entire interface calls class methods such as new against the class name to create instances, and then calls instance methods against those instances.

    [ Team LiB ] Previous Section Next Section