In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] writes: >Hi all, > >Whats the difference between class methods and instance methods on perl ?
In any language, the difference between an instance method and a class method is that an instance method operates on an instance and a class method operates on the class. Now in Perl the usual kind of straightjackets that other O-O languages have don't exist, so the lines get blurred; you can write methods that are both class and instance methods. Also, there is no class data in the usual sense and the notion of object data is somewhat different from the way other O-O languages see it. An instance is a dynamically created data structure that is returned from a class method called a constructor; the instance knows what class it belongs to and when you call a method on it, Perl knows what package to look in for that method. An instance method ought to do something with that instance, but nothing stops it from just going and doing something else entirely. Literally, though, the difference between the two types of method in Perl is their first argument: a class method receives the name of the class in a string as the first argument, an instance method receives the object it was called on as the first argument. -- Peter Scott http://www.perldebugged.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]