Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Creating flexible method accessor

by puterboy (Scribe)
on Feb 02, 2014 at 04:13 UTC ( #1073029=note: print w/ replies, xml ) Need Help??


in reply to Creating flexible method accessor

One other question..
I would like to define this subroutine in a package and then run the routine from other packages where I actually want the actual accessors to live. However, it seems that the mk_accessor routine creates all the accessors in the name-space of the package where the mk_accessor subroutine is defined rather than the one where it is run.

Is there any easy/clean way to have the accessor subroutines created in the namespace of the package where mk_accessor is run?


Comment on Re: Creating flexible method accessor
Re^2: Creating flexible method accessor
by Anonymous Monk on Feb 02, 2014 at 04:24 UTC

    Sub::Install (recommended) or:

    my ($caller_package) = caller; ... no strict 'refs'; *{"${caller_package}::$name"} = $accessor;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2014-11-27 01:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (178 votes), past polls