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


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.




Intermediate Perl
Intermediate Perl
ISBN: 0596102062
EAN: 2147483647
Year: N/A
Pages: 238

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net