Приглашаем посетить
Кюхельбекер (kyuhelbeker.lit-info.ru)

Section 3.6.  A More Typical Object-Oriented Module: Math::BigInt

Previous
Table of Contents
Next

3.6. A More Typical Object-Oriented Module: Math::BigInt

So as not to get dismayed about how "un-OO" the File::Spec module seems since it doesn't have objects, let's look at yet another core module, Math::BigInt, which can handle integers beyond Perl's native reach.[*]

[*] Behind the scenes, Perl is limited by the architecture it's on. It's one of the few places where the hardware shows through.

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

As before, this module imports nothing. Its entire interface uses class methods, such as new, against the class name to create instances, and then calls instance methods, such as bpow and bstr, against those instances.


Previous
Table of Contents
Next