Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

overriding a methods.

by rfb (Sexton)
on Jan 04, 2002 at 04:31 UTC ( [id://136161]=perlquestion: print w/replies, xml ) Need Help??

rfb has asked for the wisdom of the Perl Monks concerning the following question: (object-oriented programming)

Would it be possible to override a method this way?
sub GD::Graph::axestype::create_x_label {
or \&GD::Graph::axestype::create_x_label = sub { I know these doesnt work because I've tried, is there another way like this?

-ryan

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: overriding a methods.
by merlyn (Sage) on Jan 04, 2002 at 18:28 UTC
    The first one works fine, provided you understand that you're compiling code which has to be compiled after the original method is compiled. So, it's fine after a use that pulls in the other module. You'll probably get a "redefining ___" warning though. The typeglob assignment has also worked for me in the past.
Re: overriding a methods.
by belg4mit (Prior) on Jan 04, 2002 at 04:54 UTC
    You could typeglob...

    *GD::Graph::axestype::create_x_label = sub {...}

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-03-29 09:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found