Perl Module Basics
string or as a reference to a subroutine. The string form is preferred since it allows
for a child class to override an overloaded method. Table 2 3 lists the overloadable
operations.
Table 2 3. Overloadable Operations
Operation Type
Symbols
Conversion
""
0+ bool
Arithmetic
+ += = * *= / /= % %= ** **= ++
String
x x= . .=
Numeric comparison
< <= > >= == != <=>
String comparison
lt le gt ge eq ne cmp
Bitwise
<< >> <<= >>= & ^ | neg ~
Logical
!
Transcendental
atan2 cos sin exp abs log sqrt int
Iteration
<>
Dereferencing
${} @{} %{} &{} *{}
Special
nomethod fallback =
This method will be called with three parameters the object itself, the variable
on the opposite side of the operator, and metadata about the operator call
including the order of the arguments.
NOTE Overloading in Perl has little in common with overloading in
other languages. For example, in C++ overloading refers to the ability
to have two functions with the same name and different parameter
types. Currently Perl does not have this ability, but rumor has it Perl 6
will change that.
Overloading Conversion
Overloading's most useful feature is not its ability to overload math operators. I'll
be covering that in a moment, but unless you're inventing new mathematical
49
49
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved