Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: RFC Class::AppendMethods

by DrManhattan (Chaplain)
on Apr 22, 2003 at 08:27 UTC ( [id://252216]=note: print w/replies, xml ) Need Help??


in reply to RFC Class::AppendMethods

Neat! A couple of suggestions: First, an insert_method() would be a useful addition to append_method(). I'd like to be able to add a subroutine that executes before an existing one instead of after. Also, your example should probably mention that the package of the method to append needs to be specified explicitly when passed as a string or it ends up in Class::AppendMethod and fails to exist. E.g.
#!/usr/bin/perl use strict; package Dummy; sub test { print "one\n"; } package main; use Class::AppendMethods 'append_method'; append_method("Dummy::test", "post_test"); sub post_test { print "two\n"; } Dummy::test;
Gives me this output:
one Undefined subroutine &Class::AppendMethods::post_test called at /home/ +matt/Class/AppendMethods.pm line 43.
Whereas
append_method("Dummy::test", "main::post_test");
or
append_method("Dummy::test", \&post_test);
... behaves as expected.

-Matt

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-25 12:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found