Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

using the Class::* Modules

by chorg (Monk)
on Apr 22, 2001 at 10:22 UTC ( [id://74542]=perlquestion: print w/replies, xml ) Need Help??

chorg has asked for the wisdom of the Perl Monks concerning the following question:

So I'm going to make some objects

I want to use one of the Class::* modules to make my life simpler re. acessors. It's great that these classes do that, but where do they put the accessors? How would I modify them?
_______________________________________________
"Intelligence is a tool used achieve goals, however goals are not always chosen wisely..."

Replies are listed 'Best First'.
Re: using the Class::* Modules
by stephen (Priest) on Apr 22, 2001 at 11:09 UTC
    I'll assume that you're talking about Class::MethodMaker. MethodMaker defines its methods on-the-fly when the class loads. When you ask "where do they put the accessors?", do you mean "where is the accessor implementation written out to a file?"? If that's what you mean, the accessor implementation isn't written out to a file-- it's just evaluated at compile-time.

    To modify these methods, you just need to define your own. To quote from the perldoc:

    To override any generated methods, it is sufficient to ensure that the overriding method is defined when Class::MethodMaker is called. Note that the use keyword introduces a BEGIN block, so you may need to define (or at least declare) your overriding method in a BEGIN block.

    stephen

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://74542]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2025-07-07 23:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.