
Coderifous
journeyman
May 29, 2002, 9:40 AM
Post #1 of 3
(748 views)
|
|
Crazy! Class method invocation with ->
|
Can't Post
|
|
I recently came across this syntax: use Xerox_Machine; Xerox_Machine->purge_papers(); This is just an example by the way, I don't know of a Xerox_Machine module in real life. Now, as is standard, inside Xerox_Machine.pm is the a bunch of code that is all preceded by a "package Xerox_Machine;". So assuming that Xerox_Machine is a properly written object-oriented module, you would need to create an object of that class to implement it's method's properly. Otherwise, you could run it's subs by saying: Xerox_Machine::purge_papers(); It surprised me that Perl would allow you to replace an object on the left side of the dereference operator with a class name. I haven't seen any documentation on that. I tested this out with some random modules and it works. Can anyone else verify? I'm running v5.6.1 Binary Build 626 from IndigoSTAR. Mystified, --jim
|