in reply to 'new' constructors
Are you asking how to make constructors? If you are, the docs that come with Perl are pretty good in this regard. If you're just confused about passing arguments on to a constructor, this oughta help you:
First, a method is the same as a subroutine. The only difference is it gets passed some extra info and is called a different way.. The @_ array contains what has been passed to the method - if the method is being called as a class method (like your constructor is) then the $_[0] will contain the class name, if it's an object method then it'll be the object itelf.
A => is very similar to a comma - essentially it is used to pass arguments by name - this is what the CGI methods generally do (this includes the constructor). Both sides of the => are in the @_ in the order they were passed - but the best thing to do after getting the class or object shifted out of @_ is to assign the whole array to a hash, and use it that way.
Hope this helsps
Cheers,
|
|---|