Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

overriding a methods.

by rfb (Sexton)
on Jan 04, 2002 at 04:31 UTC ( #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?


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?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2021-11-28 12:30 GMT
Find Nodes?
    Voting Booth?

    No recent polls found